The ng-ebi-authorization is a simple authentication Angular library that relies on EBI's Authentication and Authorization Profile (AAP) infrastructure. After successful login, a JWT token is stored on the browser (via cookie, local or session storage).
Because of CORS, if the library is tested against 'explore.api.aai.ebi.ac.uk' origin should be localhost:4200.
To install this library, run:
npm install --save ng-ebi-authorization @auth0/angular-jwt or yarn add ng-ebi-authorization @auth0/angular-jwt
|Angular version||ng-ebi-authorization version|
|>=5 <6||<= email@example.com (deprecated)|
|>=6 <8||>= firstname.lastname@example.org (deprecated) or email@example.com|
ng-ebi-authorization is an updated version of angular-aap-auth.
Consuming the library
The library exposes user information through
User objects, which have information that's usually required for web application to work:
- The unique identifier (
uid): if a unique identifier has to be used, use this field.
- Name (
name): the full name of the user, for display purposes
- Nickname (
nickname): if the user is in a local aap account, it will contain the username, otherwise will have a weird string.
- Email (
- Domains (
domains): not directly provided because they may be misused. The checking of domains should be done always server-side. If the domains information wants to be shown to the user as information it can still be done, check the Advanced usage to see how to expose arbitrary token claims, or the embedded app.
In your Angular
The default configuration uses localStorage to save the JWT token under the key 'id_token'. See Advanced usage for a more fine grained configuration.
Example use on a component:
Advanced module configuration:
Example on how to get specific claims:
Want to help?
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing.
Apache 2.0 © EMBL - European Bioinformatics Institute