[ADF-3938] withCredentials TRUE the authguard should be skipped (#4259)

* should skip authguard if withCredentials is true

* missing comma

* common auth guard fix
This commit is contained in:
Eugenio Romano
2019-02-05 00:31:32 +00:00
committed by GitHub
parent bf718d905f
commit da379eefd7
7 changed files with 80 additions and 40 deletions

View File

@@ -25,7 +25,9 @@ import { OauthConfigModel } from '../models/oauth-config.model';
providedIn: 'root'
})
export class AuthGuardBpm implements CanActivate, CanActivateChild {
constructor(private authService: AuthenticationService, private router: Router, private appConfig: AppConfigService) {}
constructor(private authService: AuthenticationService, private router: Router, private appConfigService: AppConfigService) {
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.checkLogin(state.url);
@@ -36,7 +38,9 @@ export class AuthGuardBpm implements CanActivate, CanActivateChild {
}
checkLogin(redirectUrl: string): boolean {
if (this.authService.isBpmLoggedIn()) {
let withCredentialsMode = this.appConfigService.get<boolean>('auth.withCredentials', false);
if (this.authService.isBpmLoggedIn() || withCredentialsMode) {
return true;
}
@@ -50,11 +54,11 @@ export class AuthGuardBpm implements CanActivate, CanActivateChild {
}
isOAuthWithoutSilentLogin() {
let oauth: OauthConfigModel = this.appConfig.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null);
let oauth: OauthConfigModel = this.appConfigService.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null);
return this.authService.isOauth() && oauth.silentLogin === false;
}
private getRouteDestinationForLogin(): string {
return this.appConfig && this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) ? this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) : 'login';
return this.appConfigService && this.appConfigService.get<string>(AppConfigValues.LOGIN_ROUTE) ? this.appConfigService.get<string>(AppConfigValues.LOGIN_ROUTE) : 'login';
}
}