@bmat/angular-authentication

This Angular module configures an AuthService that will take care of:

Usage no npm install needed!

<script type="module">
  import bmatAngularAuthentication from 'https://cdn.skypack.dev/@bmat/angular-authentication';
</script>

README

@bmat/angular-authentication

This Angular module configures an AuthService that will take care of:

  • Parsing callbacks,
  • Requesting SSO authentications,
  • Polling session data, both to invalidae and renew sessions.

Usage

To enable authentication in the SPA, you need to import the module,

    @NgModule({
        imports: [
            ...other imports,
            AuthenticationModule.forRoot({
                tokenGetter,
                webCustomData: Auth0LockOptions,
                authOptions: WebAuthOptions,
            }),
        ],
        ...
    })
    export AppModule {}

If you need to call an API with the token, you need to add the interceptors with the same tokenGetter function. The recommended way is to use the dependency @auth0/angular-jwt:

    @NgModule({
        imports: [
            ...other imports,
            JwtModule.forRoot({
                config: {
                    tokenGetter,
                    whitelistedDomains: [
                    new RegExp('bmat.com'),
                    new RegExp('localhost'),
                    new RegExp('^null

),
                    ],
                },
            }),
        ],
        ...
    })
    export AppModule {}

Import the JwtModule after AuthenticationModule if you require additional options.

Guards

The module exports AuthenticatedGuard. If the user is not logged when accessing a guarded route, it will call the logout functions.