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
Methods
generateSRPData()
staticgenerateSRPData(username,password):SRPData
Based on the username and password, it generates a salt and verifier to configure a SRP user
Parameters
| Parameter | Type | Description |
|---|---|---|
username | string | |
password | string |
Returns
getCurrentUser()
staticgetCurrentUser():string
Return the tag of the current authenticated user.
Returns
string
The tag of the current user
getIDPNames()
staticgetIDPNames():string[]
Retrieve the IDP names that can be used for SSO login
Returns
string[]
getIDPToken()
staticgetIDPToken():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()
staticgetState():AuthState
Return the current state of the authentication manager
Returns
the current state
Deprecated
use Auth.isAuthenticated instead
getToken()
staticgetToken():string
Return the token currently used to identify the current session.
Returns
string
The current token
Deprecated
getUserFromToken()
staticgetUserFromToken(token):Promise<string>
Retrieve the user tag associated to the specified token
Parameters
| Parameter | Type | Description |
|---|---|---|
token | string |
Returns
Promise<string>
getUserToken()
staticgetUserToken():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
isAuthenticated()
staticisAuthenticated(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
| Parameter | Type | Description |
|---|---|---|
context | Context | The brick context |
Returns
Observable<boolean>
An Observable
loginOpenID()
staticloginOpenID():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()
staticloginSAML():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()
staticloginSRP(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
| Parameter | Type | Description |
|---|---|---|
username | string | the username |
password | string | the password |
Returns
Promise<void>
Throws
If the provider's configuration is incorrect.
loginSSO()
staticloginSSO(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
| Parameter | Type | Description |
|---|---|---|
idpName? | string | the 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()
staticloginToken(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
| Parameter | Type | Description |
|---|---|---|
username | string | the username |
token | string | the token |
Returns
Promise<void>
logout()
staticlogout():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()
staticobserveUser(context):Observable<string>
Returns an Observable that is updated each time the user tag changes.
Parameters
| Parameter | Type | Description |
|---|---|---|
context | Context | The brick context |
Returns
Observable<string>
An Observable
refreshToken()
staticrefreshToken():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()
staticsendKeepAlive():void
Refresh the session token to keep it alive.
Returns
void
Deprecated
use Auth.refreshToken instead