ng-ebi-authorization
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.
Installation
To install this library, run:
npm install --save ng-ebi-authorization @auth0/angular-jwt
or
yarn add ng-ebi-authorization @auth0/angular-jwt
Compatibility table
Angular version | ng-ebi-authorization version |
---|---|
>=5 <6 | <= angular-aap-auth@1.0.0-alpha.7 (deprecated) |
>=6 <8 | >= angular-aap-auth@1.0.0-alpha.8 (deprecated) or ng-ebi-authorization@1.0.0-beta.1 |
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 (
email
): the account's email, this is for information only and several accounts may have the same username. - 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 AppModule
(app.module.ts):
;; ;;; ;
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 usage
Advanced module configuration:
;; ;;; ; // Optional
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.
License
Apache 2.0 © EMBL - European Bioinformatics Institute