0.0.32 • Published 3 years ago
@piges/auth-angular v0.0.32
PigesAngularAuth
Library for use security funcionality of piges PaaS in angular
Installation
npm i @piges/auth-angular
Usage
Import and configure module
// myApp.module.ts
import { PigesAuthModule, PIGES_CONFIG, IPigesConfig } from '@piges/auth-angular';
const pigesConfig = {
clientId: '-----------------------',
redirectUrl: 'https://your-app-url.tld/piges/auth/callback',
//idp_identifier: '',
//clientSecret: '',
}
@NgModule({
imports: [
...
PigesAuthModule
],
providers: [
{
provide: PIGES_CONFIG,
useValue: { pigesConfig }
}
],
})
export class MyAppModule { }
Use PigesAuthGuard for protect your route
// myApp.route.ts
import { PigesAuthGuard } from '@piges/auth-angular';
const routes: Routes = [
{
path: 'secure-page',
canActivate : [
PigesAuthGuard
],
component: SecureComponent,
},
...
];
Manage the login redirect and login callback with route
// myApp.route.ts
import { PigesAuthLoginComponent, PigesAuthCallbackComponent } from '@piges/auth-angular';
const routes: Routes = [
{
path: 'piges/auth',
children: [
{
path: 'login',
component: PigesAuthLoginComponent,
},
{
path: 'callback',
component: PigesAuthCallbackComponent
},
]
},
...
];
Get user info in your component
// my.component.ts
import { PigesAuthService } from '@piges/auth-angular';
export class MyComponent {
constructor(
private pigesAuthService: PigesAuthService,
) {}
userInfo: any = {};
ngOnInit(): void {
this.loadUser();
}
async loadUser() {
this.userInfo = await this.pigesAuthService.getUser();
}
}
License
0.0.32
3 years ago
0.0.20
3 years ago
0.0.21
3 years ago
0.0.22
3 years ago
0.0.23
3 years ago
0.0.24
3 years ago
0.0.25
3 years ago
0.0.18
3 years ago
0.0.19
3 years ago
0.0.30
3 years ago
0.0.31
3 years ago
0.0.26
3 years ago
0.0.27
3 years ago
0.0.28
3 years ago
0.0.17
3 years ago
0.0.16
3 years ago
0.0.15
3 years ago
0.0.14
3 years ago
0.0.13
3 years ago
0.0.12
3 years ago
0.0.11
3 years ago
0.0.10
3 years ago
0.0.9
3 years ago
0.0.8
3 years ago
0.0.7
3 years ago
0.0.6
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago