diff --git a/cspell.json b/cspell.json index 15a46bcc35..f86d5fc0dd 100644 --- a/cspell.json +++ b/cspell.json @@ -5,6 +5,7 @@ "activiti", "adhoc", "afts", + "appkey", "Arial", "arrowdown", "arrowup", diff --git a/lib/core/src/lib/auth/services/user-access.service.spec.ts b/lib/core/src/lib/auth/services/user-access.service.spec.ts index b69523d0da..c2081709fe 100644 --- a/lib/core/src/lib/auth/services/user-access.service.spec.ts +++ b/lib/core/src/lib/auth/services/user-access.service.spec.ts @@ -155,6 +155,15 @@ describe('UserAccessService', () => { expect(getAccessFromApiSpy).toHaveBeenCalledWith({ url: `${fakeIdentityHost}/identity-adapter-service/v1/roles` }); }); + it('should the url contain appkey if its present in app config', async () => { + const fakeIdentityHost = 'https://fake-identity-host.fake.com'; + appConfigService.config.bpmHost = fakeIdentityHost; + appConfigService.config.application.key = 'fake-app-key'; + await userAccessService.fetchUserAccess(); + + expect(getAccessFromApiSpy).toHaveBeenCalledWith({ url: `${fakeIdentityHost}/identity-adapter-service/v1/roles` , queryParams: { appkey: 'fake-app-key' } }); + }); + it('should not fetch the access from the API if is not configured with OAUTH', async () => { appConfigService.config.authType = 'BASIC'; await userAccessService.fetchUserAccess(); diff --git a/lib/core/src/lib/auth/services/user-access.service.ts b/lib/core/src/lib/auth/services/user-access.service.ts index ae65f21afb..6352774b34 100644 --- a/lib/core/src/lib/auth/services/user-access.service.ts +++ b/lib/core/src/lib/auth/services/user-access.service.ts @@ -55,7 +55,10 @@ export class UserAccessService { private async fetchAccessFromApi() { const url = `${this.identityHost}/${IDENTITY_MICRO_SERVICE_INGRESS}/v1/roles`; - await this.oAuth2Service.get({ url }) + const appkey = this.appConfigService.get('application.key'); + const opts = appkey ? { url, queryParams: { appkey } } : { url }; + + await this.oAuth2Service.get(opts) .pipe( catchError(() => of({ globalAccess: {