alfresco-ng2-components/lib/core/services/auth-guard-ecm.service.ts
Martin Muller f0189efd5a [ACA-2755] [SSO] Unable to access a private url after a public url was loaded in the same browser tab (#5363)
* If silentlogin do implicitLogin

* If silentlogin do implicitLogin

* Unit tests

* Unit tests Trigger new run

* Authguard should return true for canActive

* adjust unit test and allow AuthGuard CanActive for the SSO case

* adjust unit test and allow AuthGuard CanActive for the SSO case

* adjust unit test and allow AuthGuard CanActive for the SSO case

* adjust unit test and allow AuthGuard CanActive for the SSO case

* Add isPublicUrl logic to authguard

* adjust unit test and allow AuthGuard CanActive for the SSO case

* Allow canActive true for public urls like /settings

* fix redirect login for SSO

* Try not using isPublicUrl from js-api as that triggers an implicit login already

* Try not using isPublicUrl from js-api as that triggers an implicit login already

* Try not using isPublicUrl from js-api as that triggers an implicit login already

* Try not using isPublicUrl from js-api as that triggers an implicit login already

* move sso silentlogin fix to ecm authguard

* Try only todo the implicitLogin if not logged in

* Try only todo the implicitLogin if not logged in

* Try only todo the implicitLogin if not logged in

* Try only todo the implicitLogin if not logged in

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* remove implicit flow parameter and pray that those process cloud tests are passing

* remove implicit flow parameter and pray that those process cloud tests are passing

* remove implicit flow parameter and pray that those process cloud tests are passing

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* move authService stuff in the login component from ngOnInit to constructor

* move authService stuff in the login component from ngOnInit to constructor

* move authService stuff in the login component from ngOnInit to constructor

* move authService stuff in the login component from ngOnInit to constructor

* not use login component for silent login anymore!

* try figuring out why process cloud is failing

* try figuring out why process cloud is failing

* reuse is PublicUrl from js-api

* reuse is PublicUrl from js-api

* revert travis changes

* revert travis changes

* Check if oauth is enabled

* Check if oauth is enabled

* Check if oauth is enabled

* Check if oauth is enabled
2020-01-25 10:15:24 +01:00

52 lines
1.8 KiB
TypeScript

/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot, Router
} from '@angular/router';
import { AuthenticationService } from './authentication.service';
import { AppConfigService } from '../app-config/app-config.service';
import { AuthGuardBase } from './auth-guard-base';
import { Observable } from 'rxjs';
import { MatDialog } from '@angular/material';
@Injectable({
providedIn: 'root'
})
export class AuthGuardEcm extends AuthGuardBase {
constructor(authenticationService: AuthenticationService,
router: Router,
appConfigService: AppConfigService,
dialog: MatDialog) {
super(authenticationService, router, appConfigService, dialog);
}
checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Observable<boolean> | Promise<boolean> | boolean {
if (this.authenticationService.isEcmLoggedIn() || this.withCredentials) {
return true;
}
this.redirectToUrl('ECM', redirectUrl);
if (!this.authenticationService.isEcmLoggedIn() && this.isSilentLogin() && !this.authenticationService.isPublicUrl()) {
this.authenticationService.ssoImplicitLogin();
return true;
}
return false;
}
}