Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • AuthService

Implements

  • OnDestroy

Index

Constructors

constructor

  • Parameters

    Returns AuthService

Properties

Private _appURL

_appURL: string

Private _authURL

_authURL: string

Private _commKeyName

_commKeyName: "AngularAapAuthUpdated" = "AngularAapAuthUpdated"

Private _currentState

_currentState: string | null = null

Private _domain

_domain: string

Private _http

_http: HttpClient

Private _loginCallbacks

_loginCallbacks: Function[] = []

Private _logoutCallbacks

_logoutCallbacks: Function[] = []

Private _rendererFactory

_rendererFactory: RendererFactory2

Private _storageRemover

_storageRemover: function

Type declaration

    • (): void
    • Returns void

Private _storageUpdater

_storageUpdater: function

Type declaration

    • (newToken: any): void
    • Parameters

      • newToken: any

      Returns void

Private _timeoutID

_timeoutID: number | null = null

Private _tokenService

_tokenService: TokenService

Private _tokenURL

_tokenURL: string

Private _unlistenEvents

_unlistenEvents: Function[]

Private _user

_user: BehaviorSubject<null | User> = new BehaviorSubject < User | null > (null)

Private config

config: AuthConfig

Methods

Private _commKeyUpdater

  • _commKeyUpdater(): void
  • Returns void

Private _createAuthHeader

  • _createAuthHeader(__namedParameters: object): HttpHeaders
  • Creates Authorization header

    Parameters

    • __namedParameters: object
      • password: string
      • username: string

    Returns HttpHeaders

    New authorization header

Private _deprecationWarning

  • _deprecationWarning(oldMethod: string, newMethod: string): void
  • Parameters

    • oldMethod: string
    • newMethod: string

    Returns void

Private _filterLoginOptions

  • Filters options that are unsecure.

    See the advance options that can be requested through the options parameter: https://api.aai.ebi.ac.uk/docs/authentication/authentication.index.html#_common_attributes

    The time to live paramenter (ttl) default value is 60 minutes. It is a big security risk to request longer ttl. If a third party gets hold of such token, means that they could use it for a day, week, year (essentially, like having the username/password).

    Parameters

    Returns void

Private _formatFragments

  • Format and filter fragment options

    params

    options

    Parameters

    Returns string

    fragment string

Private _getClaim

  • _getClaim(claim: string): string
  • Parameters

    • claim: string

    Returns string

Private _listenChangesFromOtherWindows

  • _listenChangesFromOtherWindows(renderer: Renderer2): Function
  • Listen to changes in the token from other windows.

    For inter-window communication messages are transmitted trough changes on a dummy storage key property: '_commKeyName'.

    Notice that changes in the '_commKeyName' produced by this class doesn't trigger this event.

    Parameters

    • renderer: Renderer2

    Returns Function

Private _listenLoginMessage

  • _listenLoginMessage(renderer: Renderer2): Function
  • Listen for login messages from other windows. These messages contain the tokens from the AAP. If a token is received then the callbacks are triggered.

    Parameters

    • renderer: Renderer2

    Returns Function

Private _messageIsAcceptable

  • _messageIsAcceptable(event: MessageEvent): boolean
  • Check if the message is coming from the same domain we use to generate the SSO URL, otherwise it's iffy and shouldn't trust it.

    Parameters

    • event: MessageEvent

    Returns boolean

Private _updateUser

  • _updateUser(): void
  • Returns void

addLogInEventListener

  • addLogInEventListener(callback: Function): number
  • Add a callback to the LogIn event.

    Parameters

    • callback: Function

      The Function called when the login event is triggered and the JWT token is received and accepted.

    Returns number

    The event registration id (necessary to unregister the event).

addLogOutEventListener

  • addLogOutEventListener(callback: Function): number
  • Add a callback to the LogOut event.

    Parameters

    • callback: Function

      The Function called when the logout event is triggered and the JWT token is received and accepted.

    Returns number

    The registration id (necessary to unregister the event).

changePasswordAAP

  • changePasswordAAP(__namedParameters: object): Observable<boolean>
  • Change password AAP account

    Parameters

    • __namedParameters: object
      • newPassword: string
      • oldPassword: string
      • username: string

    Returns Observable<boolean>

    true when password is successfully changed

createAAPaccount

  • createAAPaccount(newUser: object): Observable<string>
  • Create AAP account

    Parameters

    • newUser: object
      • Optional email?: undefined | string
      • Optional name?: undefined | string
      • Optional organization?: undefined | string
      • password: string
      • username: string

    Returns Observable<string>

    uid of the new user

getSSOURL

  • Produces a URL that allows logging into the single sign on (SSO) page. The URL cans be opened in a new tab using target="_blank", or in a new window using window.open().

    See method _filterLoginOptions regarding security risks of certain LoginOptions.

    Parameters

    Returns string

    The SSO URL.

logOut

  • logOut(): void
  • Functions that logs out the user. It triggers the logout callbacks. It is an arrow function (lambda) because in that way it has a reference to 'this' when used in setTimeout call.

    Returns void

loginAAP

  • loginAAP(user: object, options?: LoginOptions): Observable<boolean>
  • Login directly through the AAP

    See method _filterLoginOptions regarding security risks of certain LoginOptions.

    Parameters

    • user: object
      • password: string
      • username: string
    • Optional options: LoginOptions

    Returns Observable<boolean>

    true if the user successfully login, otherwise false

ngOnDestroy

  • ngOnDestroy(): void
  • Returns void

openLoginTab

  • Functions that opens a tab (in modern browser).

    See method _filterLoginOptions regarding security risks of certain LoginOptions.

    Parameters

    Returns void

openLoginWindow

  • openLoginWindow(options?: LoginOptions, width?: number, height?: number, left?: number, top?: number): void
  • Functions that opens a window instead of a tab.

    See method _filterLoginOptions regarding security risks of certain LoginOptions.

    Parameters

    • Optional options: LoginOptions
    • Default value width: number = 650

      Pixel width of the login window.

    • Default value height: number = 1000

      Pixel height of the login window.

    • Default value left: number = -1

      Position of the left corners. If it is a negative number it centres the login window on the screen.

    • Default value top: number = -1

      Position of the top corners. If it is a negative number it centres the login window on the screen.

    Returns void

refresh

  • refresh(): Observable<boolean>
  • Refresh token

    Returns Observable<boolean>

    true when token is successfully refreshed

removeLogInEventListener

  • removeLogInEventListener(id: number): boolean
  • Remove a callback from the LogIn event.

    Parameters

    • id: number

      The id given when event listener was added.

    Returns boolean

    true when remove successfully, false otherwise.

removeLogOutEventListener

  • removeLogOutEventListener(id: number): boolean
  • Remove a callback from the LogOut event.

    Parameters

    • id: number

      The id given when event listener was added.

    Returns boolean

    true when remove successfully, false otherwise.

tabOpen

  • deprecated

    use openLoginTab method instead since version 1.0.0-beta.5. tabOpen will be deleted in version 1.0.0

    Parameters

    Returns void

user

  • user(): Observable<User | null>
  • Returns Observable<User | null>

windowOpen

  • windowOpen(options?: LoginOptions, width?: number, height?: number, top?: number, left?: number): void
  • deprecated

    use openLoginWindow method instead (top and left arguments are inverted in the new method) since version 1.0.0-beta.5. windowOpen will be deleted in version 1.0.0

    Parameters

    • Optional options: LoginOptions
    • Default value width: number = 650
    • Default value height: number = 1000
    • Default value top: number = -1
    • Default value left: number = -1

    Returns void

Generated using TypeDoc