mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-08-07 17:48:54 +00:00
[AAE-12511] implement OIDC authentication capabilities in ADF (#7856)
* feat: add custom AlfrescoApiHttpClient [ci:force]
* feat: update configs
* feat: move api to follow second entry point structure
* feat: add auth module [ci:force]
* Fix rebasing issues
* Isolate oidc package as subfolder
* Canary mode
* [AAE-12498] Fix unit test should load external settings: resolve reponse data instead returning default config
* [AAE-12498] Set @nrwl/eslint-plugin-nx@14.5.4 version to fix lint job that failed because of the 14.8.6 version (https://github.com/Alfresco/alfresco-ng2-components/actions/runs/4165060892/jobs/7207651856\#step:5:3379)
* [AAE-12498] Fix stories:build-storybook:ci issues
* [AAE-7991] cherry-pick e935f7b0b1
from repo https://github.com/Alfresco/alfresco-ng2-components/pull/7818: send onLogin to initialize acs version to fix [C362242] on canary configuration
* [AAE-12498] Fix security hotspot: fix unsafe pseudorandom number generator
* test: add missing tests for oidc-auth.guard
* test: fix lint issues
* chore: remove assignment in return
* [AAE-12498] Remove warning comment because we already know we're doing breaking changes
* [AAE-12498] Add auth-config.service unit tests
* [AAE-12498] Remove getUserProfile from auth service
---------
Co-authored-by: Andras Popovics <popovics@ndras.hu>
Co-authored-by: Amedeo Lepore <amedeo.lepore@hyland.com>
This commit is contained in:
@@ -43,23 +43,13 @@ export class AlfrescoApiService {
|
||||
return this.alfrescoApi;
|
||||
}
|
||||
|
||||
constructor(
|
||||
protected appConfig: AppConfigService,
|
||||
protected storageService: StorageService) {
|
||||
}
|
||||
constructor(protected appConfig: AppConfigService, protected storageService: StorageService) {}
|
||||
|
||||
async load() {
|
||||
try {
|
||||
await this.appConfig.load();
|
||||
this.storageService.prefix = this.appConfig.get<string>(AppConfigValues.STORAGE_PREFIX, '');
|
||||
this.getCurrentAppConfig();
|
||||
async load(config: AlfrescoApiConfig): Promise<void> {
|
||||
this.currentAppConfig = config;
|
||||
|
||||
if (this.currentAppConfig.authType === 'OAUTH') {
|
||||
this.idpConfig = await this.appConfig.loadWellKnown(this.currentAppConfig.oauth2.host);
|
||||
if (config.authType === 'OAUTH') {
|
||||
this.mapAlfrescoApiOpenIdConfig();
|
||||
}
|
||||
} catch {
|
||||
throw new Error('Something wrong happened when calling the app.config.json');
|
||||
}
|
||||
|
||||
this.initAlfrescoApiWithConfig();
|
||||
@@ -69,7 +59,6 @@ export class AlfrescoApiService {
|
||||
async reset() {
|
||||
this.getCurrentAppConfig();
|
||||
if (this.currentAppConfig.authType === 'OAUTH') {
|
||||
this.idpConfig = await this.appConfig.loadWellKnown(this.currentAppConfig.oauth2.host);
|
||||
this.mapAlfrescoApiOpenIdConfig();
|
||||
}
|
||||
this.initAlfrescoApiWithConfig();
|
||||
@@ -84,7 +73,8 @@ export class AlfrescoApiService {
|
||||
return oauth;
|
||||
}
|
||||
|
||||
private mapAlfrescoApiOpenIdConfig() {
|
||||
private async mapAlfrescoApiOpenIdConfig() {
|
||||
this.idpConfig = await this.appConfig.loadWellKnown(this.currentAppConfig.oauth2.host);
|
||||
this.currentAppConfig.oauth2.tokenUrl = this.idpConfig.token_endpoint;
|
||||
this.currentAppConfig.oauth2.authorizationUrl = this.idpConfig.authorization_endpoint;
|
||||
this.currentAppConfig.oauth2.logoutUrl = this.idpConfig.end_session_endpoint;
|
||||
@@ -117,11 +107,15 @@ export class AlfrescoApiService {
|
||||
if (this.alfrescoApi && this.isDifferentConfig(this.lastConfig, this.currentAppConfig)) {
|
||||
this.alfrescoApi.setConfig(this.currentAppConfig);
|
||||
} else {
|
||||
this.alfrescoApi = new AlfrescoApi(this.currentAppConfig);
|
||||
this.alfrescoApi = this.createInstance(this.currentAppConfig);
|
||||
}
|
||||
this.lastConfig = this.currentAppConfig;
|
||||
}
|
||||
|
||||
createInstance(config: AlfrescoApiConfig): AlfrescoApi {
|
||||
return new AlfrescoApi(config);
|
||||
}
|
||||
|
||||
isDifferentConfig(lastConfig: AlfrescoApiConfig, newConfig: AlfrescoApiConfig) {
|
||||
return JSON.stringify(lastConfig) !== JSON.stringify(newConfig);
|
||||
}
|
||||
|
Reference in New Issue
Block a user