IAuthenticationProvider
Defines authentication provider to use when instance of IAnalyticalBackend discovers that the current session is not authentication.
export interface IAuthenticationProvider
Properties
Property | Modifiers | Type | Description |
|---|---|---|---|
boolean | Instructs the consumer which uses this provider to not cache authentication in any ways. Note: It does not affect calls deduplication like debouncing or throttling. If true, the consumer will always call authenticate if there is a need to authenticate user (like if some request respons with 401). If false, the consumer is allowed to cache the authenticated principal and reuse it for subsequent requests. This is the current behavior. It is here because some implementations of authentication works with time restricted sessions. It means the session can expire during user activity and the consumer should call authenticate again and not just reuse the cached principal. FIXME: I believe this should be true by default and if authentication provider wants to do some caching, it should implement it on its own. In this case, this property should be removed from the interface. But for now I dont have enough time to refactor this, so Im creating this backwards compatible solution. See JIRA ticket F1-1256 for more details. | ||
(Optional) Specify function to be called when the Analytical Backend raises a NotAuthenticated error. |
Methods
Method | Description |
|---|---|
Perform authentication. | |
Clear existing authentication. | |
Returns the currently authenticated principal, or undefined if not authenticated. Does not trigger authentication if no principal is available. | |
(Optional) Perform custom initialization of the client that the Analytical Backend uses to communicate with the server. |
Property details
IAuthenticationProvider.disablePrincipalCacheproperty
Instructs the consumer which uses this provider to not cache authentication in any ways. Note: It does not affect calls deduplication like debouncing or throttling.
If true, the consumer will always call authenticate if there is a need to authenticate user (like if some request respons with 401). If false, the consumer is allowed to cache the authenticated principal and reuse it for subsequent requests. This is the current behavior.
It is here because some implementations of authentication works with time restricted sessions. It means the session can expire during user activity and the consumer should call authenticate again and not just reuse the cached principal.
FIXME: I believe this should be true by default and if authentication provider wants to do some caching, it should implement it on its own. In this case, this property should be removed from the interface. But for now I dont have enough time to refactor this, so Im creating this backwards compatible solution. See JIRA ticket F1-1256 for more details.
disablePrincipalCache: boolean;
IAuthenticationProvider.onNotAuthenticatedproperty
Specify function to be called when the Analytical Backend raises a NotAuthenticated error.
onNotAuthenticated?: NotAuthenticatedHandler;
Method details
IAuthenticationProvider.authenticate()method
Perform authentication.
authenticate(context: IAuthenticationContext): Promise<IAuthenticatedPrincipal>;
Parameters
Parameter | Type | Description |
|---|---|---|
context | context in which the authentication is done |
Returns
Promise<IAuthenticatedPrincipal>
IAuthenticationProvider.deauthenticate()method
Clear existing authentication.
deauthenticate(context: IAuthenticationContext, returnTo?: string): Promise<void>;
Parameters
Parameter | Type | Description |
|---|---|---|
context | context in which the authentication is done | |
returnTo | string | (Optional) url to redirect after successful logout |
Returns
Promise<void>
IAuthenticationProvider.getCurrentPrincipal()method
Returns the currently authenticated principal, or undefined if not authenticated. Does not trigger authentication if no principal is available.
getCurrentPrincipal(context: IAuthenticationContext): Promise<IAuthenticatedPrincipal | null>;
Parameters
Parameter | Type | Description |
|---|---|---|
context |
Returns
Promise<IAuthenticatedPrincipal | null>
IAuthenticationProvider.initializeClient()method
Perform custom initialization of the client that the Analytical Backend uses to communicate with the server.
initializeClient?(client: any): void;
Parameters
Parameter | Type | Description |
|---|---|---|
client | any | an instance of client |
Returns
void
Remarks
If implemented, this function WILL BE called by the backend every time a new instance of API client is created.
Note: the configuration and construction of Analytical Backend instance is cumulative. Backend implementations MAY create multiple instances of clients during construction.