Limpieza de código
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { noDiscoveryAuthConfig } from './auth-no-discovery.config';
|
||||
import { Component } from '@angular/core';
|
||||
import { OAuthService, NullValidationHandler } from 'angular-oauth2-oidc';
|
||||
import { Router } from '@angular/router';
|
||||
@@ -19,12 +18,12 @@ export class AppComponent {
|
||||
this.oauthService.events
|
||||
.pipe(filter((e) => e.type === 'token_received'))
|
||||
.subscribe((_) => {
|
||||
console.debug('state', this.oauthService.state);
|
||||
console.log('state', this.oauthService.state);
|
||||
this.oauthService.loadUserProfile();
|
||||
});
|
||||
}
|
||||
|
||||
private configureCodeFlow() {
|
||||
private configureCodeFlow(): void {
|
||||
this.oauthService.configure(authCodeFlowConfig);
|
||||
this.oauthService.loadDiscoveryDocumentAndTryLogin().then((_) => {
|
||||
if (useHash) {
|
||||
@@ -35,67 +34,4 @@ export class AppComponent {
|
||||
// Optional
|
||||
this.oauthService.setupAutomaticSilentRefresh();
|
||||
}
|
||||
|
||||
//
|
||||
// Below you find further examples for configuration functions
|
||||
//
|
||||
|
||||
private configureWithoutDiscovery() {
|
||||
this.oauthService.configure(noDiscoveryAuthConfig);
|
||||
this.oauthService.tokenValidationHandler = new NullValidationHandler();
|
||||
this.oauthService.tryLogin();
|
||||
}
|
||||
|
||||
private configureAuth() {
|
||||
//
|
||||
// This method demonstrated the old API; see configureWithNewConfigApi for new one
|
||||
//
|
||||
|
||||
// URL of the SPA to redirect the user to after login
|
||||
this.oauthService.redirectUri = window.location.origin + '/index.html';
|
||||
|
||||
// URL of the SPA to redirect the user after silent refresh
|
||||
this.oauthService.silentRefreshRedirectUri =
|
||||
window.location.origin + '/silent-refresh.html';
|
||||
|
||||
// The SPA's id. The SPA is registerd with this id at the auth-server
|
||||
this.oauthService.clientId = 'spa-demo';
|
||||
|
||||
// set the scope for the permissions the client should request
|
||||
// The first three are defined by OIDC. The 4th is a usecase-specific one
|
||||
this.oauthService.scope = 'openid profile email voucher';
|
||||
|
||||
// Url of the Identity Provider
|
||||
this.oauthService.issuer =
|
||||
'https://steyer-identity-server.azurewebsites.net/identity';
|
||||
|
||||
this.oauthService.tokenValidationHandler = new NullValidationHandler();
|
||||
|
||||
this.oauthService.events.subscribe((e) => {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.debug('oauth/oidc event', e);
|
||||
});
|
||||
|
||||
// Load Discovery Document and then try to login the user
|
||||
this.oauthService.loadDiscoveryDocument().then((doc) => {
|
||||
this.oauthService.tryLogin();
|
||||
});
|
||||
|
||||
this.oauthService.events
|
||||
.pipe(filter((e) => e.type === 'token_expires'))
|
||||
.subscribe((e) => {
|
||||
// tslint:disable-next-line:no-console
|
||||
console.debug('received token_expires event', e);
|
||||
this.oauthService.silentRefresh();
|
||||
});
|
||||
}
|
||||
|
||||
private configurePasswordFlow() {
|
||||
// Set a dummy secret
|
||||
// Please note that the auth-server used here demand the client to transmit a client secret, although
|
||||
// the standard explicitly cites that the password flow can also be used without it. Using a client secret
|
||||
// does not make sense for a SPA that runs in the browser. That's why the property is called dummyClientSecret
|
||||
// Using such a dummy secreat is as safe as using no secret.
|
||||
this.oauthService.dummyClientSecret = 'geheim';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user