Skip to main content
Version: 2.13

Auth

A static class that gathers all the required methods to handle the authentication and sessions with Olympe.

Constructors​

new Auth()​

new Auth(): Auth

Returns​

Auth

Methods​

generateSRPData()​

static generateSRPData(username, password): SRPData

Based on the username and password, it generates a salt and verifier to configure a SRP user

Parameters​

ParameterTypeDescription
usernamestring
passwordstring

Returns​

SRPData


getCurrentUser()​

static getCurrentUser(): string

Return the tag of the current authenticated user.

Returns​

string

The tag of the current user


getIDPNames()​

static getIDPNames(): string[]

Retrieve the IDP names that can be used for SSO login

Returns​

string[]


getIDPToken()​

static getIDPToken(): string

Return the IDP token (zipped & base64 encoded XML) for the current user.

Returns​

string

The current IDP token

Deprecated​

use Auth.getUserToken instead


getState()​

static getState(): AuthState

Return the current state of the authentication manager

Returns​

AuthState

the current state

Deprecated​

use Auth.isAuthenticated instead


getToken()​

static getToken(): string

Return the token currently used to identify the current session.

Returns​

string

The current token

Deprecated​

see Auth.getUserToken


getUserFromToken()​

static getUserFromToken(token): Promise<string>

Retrieve the user tag associated to the specified token

Parameters​

ParameterTypeDescription
tokenstring

Returns​

Promise<string>


getUserToken()​

static getUserToken(): UserToken

Returns the full token of the current user. It contains:

  • the username, the unique ID of the user for the IDP used
  • the tag of the user in the datacloud
  • the protocol and IDP used
  • the raw payload sent by the IDP (eg: JWT for OAuth2 or SAML response).

Returns​

UserToken


isAuthenticated()​

static isAuthenticated(context): Observable<boolean>

Returns an Observable that is updated each time the authentication status changes. If the user is authenticated, gets true, otherwise (e.g. Guest) get false.

Parameters​

ParameterTypeDescription
contextContextThe brick context

Returns​

Observable<boolean>

An Observable


loginOpenID()​

static loginOpenID(): Promise<void>

Try to login using the configured OpenID Provider. Returns a promise resolved when logged in or that catches an error if the login is not valid.

Returns​

Promise<void>

Deprecated​

use Auth.loginSSO instead

Throws​

If the provider's configuration is incorrect.


loginSAML()​

static loginSAML(): Promise<void>

Try to login using SAML protocol with the specified username and password. Returns a promise resolved when logged in or that catches an error if refused.

Returns​

Promise<void>

Deprecated​

use Auth.loginSSO instead

Throws​

If the provider's configuration is incorrect.


loginSRP()​

static loginSRP(username, password): Promise<void>

Try to login using SRP protocol with the specified username and password. Returns a promise resolved when logged in or that catches an error if refused.

Parameters​

ParameterTypeDescription
usernamestringthe username
passwordstringthe password

Returns​

Promise<void>

Throws​

If the provider's configuration is incorrect.


loginSSO()​

static loginSSO(idpName?): Promise<void>

Try to login using SSO. Returns a promise resolved when logged in or an error if the login is not valid.

Parameters​

ParameterTypeDescription
idpName?stringthe IDP name which should be used. If not specified, take the first available SSO.

Returns​

Promise<void>

Throws​

If the IDP name is incorrect.


loginToken()​

static loginToken(username, token): Promise<void>

Try to login using the specified token for the user. Returns a promise resolved when logged in or that catches an error if the token is not valid.

Parameters​

ParameterTypeDescription
usernamestringthe username
tokenstringthe token

Returns​

Promise<void>


logout()​

static logout(): Promise<void>

Log out the current user and invalidate its session token. It returns a promise resolved when the operation is done.

Returns​

Promise<void>


observeUser()​

static observeUser(context): Observable<string>

Returns an Observable that is updated each time the user tag changes.

Parameters​

ParameterTypeDescription
contextContextThe brick context

Returns​

Observable<string>

An Observable


refreshToken()​

static refreshToken(): Promise<void>

Refresh the expiration time for the current authentication token. In case of OAuth2 authentication, it uses the refresh token associated to generate a new access token.

Returns​

Promise<void>

Promise success when the refresh is done


sendKeepAlive()​

static sendKeepAlive(): void

Refresh the session token to keep it alive.

Returns​

void

Deprecated​

use Auth.refreshToken instead