Fix OidcAuthenticationService export (#9711)

* fix import

* fix service location and exports
This commit is contained in:
Denys Vuika
2024-05-22 09:16:12 -04:00
committed by GitHub
parent 2d347acda1
commit 6b45bc2b96
21 changed files with 65 additions and 77 deletions

View File

@@ -23,7 +23,7 @@ import { MatDialog } from '@angular/material/dialog';
import { StorageService } from '../../common/services/storage.service';
import { Observable } from 'rxjs';
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
import { OidcAuthenticationService } from '../services/oidc-authentication.service';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
protected get withCredentials(): boolean {

View File

@@ -23,7 +23,7 @@ import { RouterStateSnapshot, Router } from '@angular/router';
import { CoreTestingModule } from '../../testing/core.testing.module';
import { MatDialog } from '@angular/material/dialog';
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
import { OidcAuthenticationService } from '../services/oidc-authentication.service';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
describe('AuthGuardService BPM', () => {
let authGuard: AuthGuardBpm;

View File

@@ -23,21 +23,22 @@ import { AuthGuardBase } from './auth-guard-base';
import { MatDialog } from '@angular/material/dialog';
import { StorageService } from '../../common/services/storage.service';
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
import { OidcAuthenticationService } from '../services/oidc-authentication.service';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
@Injectable({
providedIn: 'root'
})
export class AuthGuardBpm extends AuthGuardBase {
constructor(authenticationService: AuthenticationService,
basicAlfrescoAuthService: BasicAlfrescoAuthService,
oidcAuthenticationService: OidcAuthenticationService,
router: Router,
appConfigService: AppConfigService,
dialog: MatDialog,
storageService: StorageService) {
super(authenticationService,basicAlfrescoAuthService, oidcAuthenticationService,router, appConfigService, dialog, storageService);
constructor(
authenticationService: AuthenticationService,
basicAlfrescoAuthService: BasicAlfrescoAuthService,
oidcAuthenticationService: OidcAuthenticationService,
router: Router,
appConfigService: AppConfigService,
dialog: MatDialog,
storageService: StorageService
) {
super(authenticationService, basicAlfrescoAuthService, oidcAuthenticationService, router, appConfigService, dialog, storageService);
}
async checkLogin(_: ActivatedRouteSnapshot, redirectUrl: string): Promise<boolean | UrlTree> {

View File

@@ -22,7 +22,7 @@ import { AuthenticationService } from '../services/authentication.service';
import { RouterStateSnapshot, Router } from '@angular/router';
import { CoreTestingModule } from '../../testing/core.testing.module';
import { MatDialog } from '@angular/material/dialog';
import { OidcAuthenticationService } from '../services/oidc-authentication.service';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
describe('AuthGuardService ECM', () => {

View File

@@ -16,30 +16,28 @@
*/
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot, Router, UrlTree
} from '@angular/router';
import { ActivatedRouteSnapshot, Router, UrlTree } from '@angular/router';
import { AuthenticationService } from '../services/authentication.service';
import { AppConfigService } from '../../app-config/app-config.service';
import { AuthGuardBase } from './auth-guard-base';
import { MatDialog } from '@angular/material/dialog';
import { StorageService } from '../../common/services/storage.service';
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
import { OidcAuthenticationService } from '../services/oidc-authentication.service';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
@Injectable({
providedIn: 'root'
})
export class AuthGuardEcm extends AuthGuardBase {
constructor(authenticationService: AuthenticationService,
basicAlfrescoAuthService: BasicAlfrescoAuthService,
oidcAuthenticationService: OidcAuthenticationService,
router: Router,
appConfigService: AppConfigService,
dialog: MatDialog,
storageService: StorageService) {
constructor(
authenticationService: AuthenticationService,
basicAlfrescoAuthService: BasicAlfrescoAuthService,
oidcAuthenticationService: OidcAuthenticationService,
router: Router,
appConfigService: AppConfigService,
dialog: MatDialog,
storageService: StorageService
) {
super(authenticationService, basicAlfrescoAuthService, oidcAuthenticationService, router, appConfigService, dialog, storageService);
}

View File

@@ -22,7 +22,7 @@ import { AuthGuard } from './auth-guard.service';
import { AuthenticationService } from '../services/authentication.service';
import { CoreTestingModule } from '../../testing/core.testing.module';
import { StorageService } from '../../common/services/storage.service';
import { OidcAuthenticationService } from '../services/oidc-authentication.service';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
describe('AuthGuardService', () => {

View File

@@ -24,24 +24,24 @@ import { JwtHelperService } from '../services/jwt-helper.service';
import { MatDialog } from '@angular/material/dialog';
import { StorageService } from '../../common/services/storage.service';
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
import { OidcAuthenticationService } from '../services/oidc-authentication.service';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
@Injectable({
providedIn: 'root'
})
export class AuthGuard extends AuthGuardBase {
ticketChangeBind: any;
constructor(private jwtHelperService: JwtHelperService,
authenticationService: AuthenticationService,
basicAlfrescoAuthService: BasicAlfrescoAuthService,
oidcAuthenticationService: OidcAuthenticationService,
router: Router,
appConfigService: AppConfigService,
dialog: MatDialog,
storageService: StorageService) {
constructor(
private jwtHelperService: JwtHelperService,
authenticationService: AuthenticationService,
basicAlfrescoAuthService: BasicAlfrescoAuthService,
oidcAuthenticationService: OidcAuthenticationService,
router: Router,
appConfigService: AppConfigService,
dialog: MatDialog,
storageService: StorageService
) {
super(authenticationService, basicAlfrescoAuthService, oidcAuthenticationService, router, appConfigService, dialog, storageService);
this.ticketChangeBind = this.ticketChange.bind(this);
@@ -57,9 +57,11 @@ export class AuthGuard extends AuthGuardBase {
this.ticketChangeRedirect(event);
}
if (event.key.endsWith(JwtHelperService.USER_ACCESS_TOKEN) &&
if (
event.key.endsWith(JwtHelperService.USER_ACCESS_TOKEN) &&
this.jwtHelperService.getValueFromToken(event.newValue, JwtHelperService.USER_PREFERRED_USERNAME) !==
this.jwtHelperService.getValueFromToken(event.oldValue, JwtHelperService.USER_PREFERRED_USERNAME)) {
this.jwtHelperService.getValueFromToken(event.oldValue, JwtHelperService.USER_PREFERRED_USERNAME)
) {
this.ticketChangeRedirect(event);
}
}

View File

@@ -16,4 +16,3 @@
*/
export * from './public-api';
export * from './oidc/public-api';

View File

@@ -19,7 +19,7 @@ import { TestBed } from '@angular/core/testing';
import { OidcAuthenticationService } from './oidc-authentication.service';
import { OAuthService, OAuthStorage } from 'angular-oauth2-oidc';
import { AppConfigService, AuthService } from '@alfresco/adf-core';
import { AUTH_MODULE_CONFIG } from '../oidc/auth-config';
import { AUTH_MODULE_CONFIG } from './auth-config';
interface MockAppConfigOAuth2 {
oauth2: {
@@ -46,7 +46,6 @@ class MockAppConfigService {
}
}
class MockOAuthService {
clientId = 'testClientId';
redirectUri = 'testRedirectUri';

View File

@@ -21,11 +21,11 @@ import { Observable, defer, EMPTY } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
import { OauthConfigModel } from '../models/oauth-config.model';
import { BaseAuthenticationService } from './base-authentication.service';
import { BaseAuthenticationService } from '../services/base-authentication.service';
import { CookieService } from '../../common/services/cookie.service';
import { JwtHelperService } from './jwt-helper.service';
import { AuthConfigService } from '../oidc/auth-config.service';
import { AuthService } from '../oidc/auth.service';
import { JwtHelperService } from '../services/jwt-helper.service';
import { AuthConfigService } from './auth-config.service';
import { AuthService } from './auth.service';
import { Minimatch } from 'minimatch';
import { HttpHeaders } from '@angular/common/http';

View File

@@ -21,3 +21,4 @@ export * from './auth.service';
export * from './oidc-auth.guard';
export * from './redirect-auth.service';
export * from './view/authentication-confirmation/authentication-confirmation.component';
export * from './oidc-authentication.service';

View File

@@ -30,7 +30,6 @@ export * from './services/identity-group.service';
export * from './services/jwt-helper.service';
export * from './services/oauth2.service';
export * from './services/user-access.service';
export * from './services/oidc-authentication.service';
export * from './basic-auth/basic-alfresco-auth.service';
export * from './basic-auth/process-auth';
@@ -49,3 +48,5 @@ export * from './models/identity-role.model';
export * from './models/user-access.model';
export * from './models/application-access.model';
export * from './oidc/public-api';

View File

@@ -22,7 +22,7 @@ import { AppConfigService } from '../../app-config/app-config.service';
import { setupTestBed } from '../../testing/setup-test-bed';
import { CoreTestingModule } from '../../testing/core.testing.module';
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
import { OidcAuthenticationService } from './oidc-authentication.service';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
declare let jasmine: any;

View File

@@ -16,7 +16,7 @@
*/
import { Injectable, Injector } from '@angular/core';
import { OidcAuthenticationService } from './oidc-authentication.service';
import { OidcAuthenticationService } from '../oidc/oidc-authentication.service';
import { BasicAlfrescoAuthService } from '../basic-auth/basic-alfresco-auth.service';
import { Observable, Subject, from } from 'rxjs';
import { HttpHeaders } from '@angular/common/http';
@@ -28,30 +28,18 @@ import { RedirectAuthService } from '../oidc/redirect-auth.service';
providedIn: 'root'
})
export class AuthenticationService implements AuthenticationServiceInterface, ee.Emitter {
onLogin: Subject<any> = new Subject<any>();
onLogout: Subject<any> = new Subject<any>();
constructor(
private injector: Injector,
private redirectAuthService: RedirectAuthService
) {
this.redirectAuthService.onLogin.subscribe(
(value) => this.onLogin.next(value)
);
constructor(private injector: Injector, private redirectAuthService: RedirectAuthService) {
this.redirectAuthService.onLogin.subscribe((value) => this.onLogin.next(value));
this.basicAlfrescoAuthService.onLogin.subscribe(
(value) => this.onLogin.next(value)
);
this.basicAlfrescoAuthService.onLogin.subscribe((value) => this.onLogin.next(value));
if (this.isOauth()) {
this.oidcAuthenticationService.onLogout.subscribe(
(value) => this.onLogout.next(value)
);
this.oidcAuthenticationService.onLogout.subscribe((value) => this.onLogout.next(value));
} else {
this.basicAlfrescoAuthService.onLogout.subscribe(
(value) => this.onLogout.next(value)
);
this.basicAlfrescoAuthService.onLogout.subscribe((value) => this.onLogout.next(value));
}
}
@@ -76,7 +64,9 @@ export class AuthenticationService implements AuthenticationServiceInterface, ee
}
addTokenToHeader(requestUrl: string, headersArg?: HttpHeaders): Observable<HttpHeaders> {
return this.isOauth() ? this.oidcAuthenticationService.addTokenToHeader(requestUrl, headersArg) : this.basicAlfrescoAuthService.addTokenToHeader(requestUrl, headersArg);
return this.isOauth()
? this.oidcAuthenticationService.addTokenToHeader(requestUrl, headersArg)
: this.basicAlfrescoAuthService.addTokenToHeader(requestUrl, headersArg);
}
isECMProvider(): boolean {
@@ -205,5 +195,4 @@ export class AuthenticationService implements AuthenticationServiceInterface, ee
isKerberosEnabled(): boolean {
return !this.isOauth() ? this.basicAlfrescoAuthService.isKerberosEnabled() : false;
}
}

View File

@@ -18,7 +18,7 @@
import { BasicAlfrescoAuthService, CoreTestingModule, LoginDialogPanelComponent } from '@alfresco/adf-core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { of } from 'rxjs';
import { OidcAuthenticationService } from '../../../auth/services/oidc-authentication.service';
import { OidcAuthenticationService } from '../../../auth/oidc/oidc-authentication.service';
describe('LoginDialogPanelComponent', () => {
let component: LoginDialogPanelComponent;

View File

@@ -29,7 +29,7 @@ import { Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { EMPTY, of, throwError } from 'rxjs';
import { OidcAuthenticationService } from '../../../auth/services/oidc-authentication.service';
import { OidcAuthenticationService } from '../../../auth/oidc/oidc-authentication.service';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {

View File

@@ -31,7 +31,7 @@ import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { AppConfigService, AppConfigValues } from '../../../app-config';
import { AuthenticationService, BasicAlfrescoAuthService } from '../../../auth';
import { OidcAuthenticationService } from '../../../auth/services/oidc-authentication.service';
import { OidcAuthenticationService } from '../../../auth/oidc/oidc-authentication.service';
import { UserPreferencesService } from '../../../common';
import { TranslationService } from '../../../translation';

View File

@@ -17,7 +17,7 @@
import { CoreTestingModule, LoginComponent, LoginFooterDirective } from '@alfresco/adf-core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { OidcAuthenticationService } from '../../auth/services/oidc-authentication.service';
import { OidcAuthenticationService } from '../../auth/oidc/oidc-authentication.service';
describe('LoginFooterDirective', () => {
let fixture: ComponentFixture<LoginComponent>;

View File

@@ -17,7 +17,7 @@
import { CoreTestingModule, LoginComponent, LoginHeaderDirective } from '@alfresco/adf-core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { OidcAuthenticationService } from '../../auth/services/oidc-authentication.service';
import { OidcAuthenticationService } from '../../auth/oidc/oidc-authentication.service';
describe('LoginHeaderDirective', () => {
let fixture: ComponentFixture<LoginComponent>;

View File

@@ -59,4 +59,3 @@ export * from './lib/common';
export * from './lib/material.module';
export * from './lib/core.module';
export { AuthModule } from './lib/auth/oidc/auth.module';

View File

@@ -21,12 +21,11 @@ import { ContentModule, ContentNodeSelectorPanelComponent, DocumentListService,
import { EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core';
import { ProcessTestingModule } from '../../../testing/process.testing.module';
import { AttachFileWidgetDialogComponent } from './attach-file-widget-dialog.component';
import { AlfrescoApiService, BasicAlfrescoAuthService } from '@alfresco/adf-core';
import { AlfrescoApiService, BasicAlfrescoAuthService, OidcAuthenticationService } from '@alfresco/adf-core';
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
import { of, throwError } from 'rxjs';
import { By } from '@angular/platform-browser';
import { Node, SiteEntry, NodeEntry, SitePaging, SitePagingList } from '@alfresco/js-api';
import { OidcAuthenticationService } from 'lib/core/src/lib/auth/services/oidc-authentication.service';
describe('AttachFileWidgetDialogComponent', () => {
let widget: AttachFileWidgetDialogComponent;