MAJ des commentaires

develop
jboinembalome 4 years ago
parent 22520add64
commit 087463e3ff
  1. 10
      src/app/shared/auth/auth.module.ts
  2. 14
      src/environments/environment.ts

@ -7,15 +7,15 @@ import { authModuleConfig } from './auth-module-config';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
/** /**
* Nous avons besoin d'une usine de stockage car le localStorage * Utilisation du localstorage pour stocker le token
* n'est pas disponible au moment de la compilation de l'AOT. (Ahead-of-time) * Voir: https://manfredsteyer.github.io/angular-oauth2-oidc/docs/additional-documentation/configure-custom-oauthstorage.html
*/ */
export function storageFactory(): OAuthStorage { export function storageFactory(): OAuthStorage {
return localStorage; return localStorage;
} }
/** /**
* Exécute la méthode qui permet d'afficher la page de connexion. * Fonction permettant d'appeler la méthode qui va démarrer la séquence de connexion initiale
* @param authService Service d'authentification * @param authService Service d'authentification
*/ */
export function init_app(authService: AuthService) { export function init_app(authService: AuthService) {
@ -44,8 +44,8 @@ export class AuthModule {
{ provide: OAuthModuleConfig, useValue: authModuleConfig }, { provide: OAuthModuleConfig, useValue: authModuleConfig },
{ provide: OAuthStorage, useFactory: storageFactory }, { provide: OAuthStorage, useFactory: storageFactory },
{ {
provide: APP_INITIALIZER, provide: APP_INITIALIZER, // Gestion de l'authentification au démarrage de l'application
useFactory: init_app, // Affiche la page de connexion au démarrage de l'application useFactory: init_app,
deps: [ AuthService ], deps: [ AuthService ],
multi: true multi: true
} }

@ -21,21 +21,19 @@ const keycloakConfig: AuthConfig = {
//dummyClientSecret: 'f27746f4-e603-441e-a256-3ddd5b19ba54', //dummyClientSecret: 'f27746f4-e603-441e-a256-3ddd5b19ba54',
dummyClientSecret: '82702d7b-e44b-4415-9c80-54774a58e1dc', dummyClientSecret: '82702d7b-e44b-4415-9c80-54774a58e1dc',
responseType: 'code', // To configure your solution for code flow + PKCE you have to set the responseType to code
silentRefreshRedirectUri: window.location.origin + '/silent-refresh.html' , responseType: 'code',
// set the scope for the permissions the client should request // set the scope for the permissions the client should request
// The first four are defined by OIDC. // The first four are defined by OIDC.
// Important: Request offline_access to get a refresh token // Important: Request offline_access to get a refresh token
// The api scope is a usecase specific one // The api scope is a usecase specific one
scope: 'openid profile email', scope: 'openid profile email',
showDebugInformation: true, useSilentRefresh: true, // Activate silent refresh for code flow
useSilentRefresh: true, // Needed for Code Flow to suggest using iframe-based refreshes silentRefreshTimeout: 5000,
silentRefreshTimeout: 5000, // For faster testing timeoutFactor: 0.25,
timeoutFactor: 0.25, // For faster testing
sessionChecksEnabled: true, sessionChecksEnabled: true,
clearHashAfterLogin: false, // https://github.com/manfredsteyer/angular-oauth2-oidc/issues/457#issuecomment-431807040, nonceStateSeparator : 'semicolon' // Real semicolon gets mangled by Keycloak's URI encoding
nonceStateSeparator : 'semicolon' // Real semicolon gets mangled by IdentityServer's URI encoding
}; };
export const environment = { export const environment = {

Loading…
Cancel
Save