This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.6.6.
[](https://gitlab.ebi.ac.uk/tools-glue/angular-aap-auth/commits/master 'test and build status')
The angular-aap-auth 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).
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Want to help?
## Code scaffolding
Want to file a bug, contribute some code, or improve documentation? Excellent!
Read up on our guidelines for [contributing][contributing].
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Installation
## Build
To install this library, run:
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
```
npm install angular-aap-auth --save
## Running unit tests
or
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
yarn add angular-aap-auth
```
## Running end-to-end tests
## Consuming the library
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
In your Angular `AppModule` (app.module.ts):
## Further help
```typescript
import{
BrowserModule
}from'@angular/platform-browser';
import{
NgModule
}from'@angular/core';
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
import{
AppComponent
}from'./app.component';
import{
AuthModule
}from'./modules/auth/auth.module';
@NgModule({
declarations:[
AppComponent
],
imports:[
BrowserModule,
AuthModule.forRoot(),
],
providers:[
],
bootstrap:[AppComponent]
})
exportclassAppModule{}
```
The default configuration uses localStorage to save the JWT token under the key
'id_token'. See [Advance usage](Advance usage) for a more fine grained configuration.
Example use on a component:
```typescript
import{
Component,
OnInit
}from'@angular/core';
import{
Observable,
}from'rxjs/Observable';
import{
map
}from'rxjs/operators';
import{
AuthService,
}from'angular-aap-auth/auth.service';
@Component({
selector:'app-root',
template:`<h1>Welcome</h1>
<button (click)="auth.windowOpen()">Login small window</button>
<button (click)="auth.tabOpen()" target="_blank">Login new tab</button>