diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2962b9a55d4d5852c481b4f68e5c1beb118e5b8f..7e2b76c2ccebb140a86a5d60592a4cdbd4dcc9fd 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -7,13 +7,43 @@ import { Component, OnInit } from '@angular/core'; import { AnalyticsService } from './@core/utils/analytics.service'; import { SeoService } from './@core/utils/seo.service'; +import { v4 as uuidv4 } from 'uuid'; +import { NbAuthOAuth2Token, NbAuthService, NbOAuth2AuthStrategy, NbOAuth2ClientAuthMethod } from '@nebular/auth'; +import { ConfigService } from '@ngx-config/core'; + @Component({ selector: 'ngx-app', template: '<router-outlet></router-outlet>', }) export class AppComponent implements OnInit { - constructor(private analytics: AnalyticsService, private seoService: SeoService) { + constructor(private analytics: AnalyticsService, private seoService: SeoService,private configService: ConfigService, + authService: NbAuthService, // force construction of the auth service + oauthStrategy: NbOAuth2AuthStrategy) { + + oauthStrategy.setOptions({ + name: 'idm', + clientId: configService.getSettings("client_id"), + clientSecret: configService.getSettings("client_secret"), + baseEndpoint: `${configService.getSettings("idmBaseURL")}/oauth2/`, + clientAuthMethod: NbOAuth2ClientAuthMethod.BASIC, + token: { + redirectUri: `${configService.getSettings("dashboardBaseURL")}/auth/callback`, + class: NbAuthOAuth2Token + }, + authorize: { + state: uuidv4(), + redirectUri: `${configService.getSettings("dashboardBaseURL")}/auth/callback`, + }, + redirect: { + success: '/pages', // welcome page path + failure: null, // stay on the same page + }, + refresh:{ + // endpoint: 'token', + // grantType: NbOAuth2GrantType.REFRESH_TOKEN, + } + }) } ngOnInit(): void { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0d6f36a56d51f87b842675d95c1373a13b6109d6..4155db2fda4571777b2c5ca5585a82ca919901d4 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -70,33 +70,14 @@ export function createTranslateLoader(http: HttpClient) { strategies: [ NbOAuth2AuthStrategy.setup({ name: 'idm', - clientId: 'b5d2fe98-3d01-4b93-b54c-acbb60772479', - clientSecret: '15964f9e-b7e3-4816-bb93-548488cfaca5', - baseEndpoint: 'http://192.168.99.100:3000/oauth2/', - clientAuthMethod: NbOAuth2ClientAuthMethod.BASIC, - token: { - redirectUri: 'http://localhost:4200/auth/callback', - class: NbAuthOAuth2Token - }, - authorize: { - state: uuidv4(), - redirectUri: 'http://localhost:4200/auth/callback', - }, - redirect: { - success: '/pages', // welcome page path - failure: null, // stay on the same page - }, - refresh:{ - // endpoint: 'token', - // grantType: NbOAuth2GrantType.REFRESH_TOKEN, - } + clientId: '' }), ], }), NbSecurityModule.forRoot({ accessControl: { ADMIN:{ - view: '*', + view: '*' }, MANAGER:{ view: ['external-app','maps','home','about','charts','lorem-ipsum'] diff --git a/src/app/oauth/services/user-information.service.ts b/src/app/oauth/services/user-information.service.ts index 2c46b653d6a2a1e4253b2bd72482121628403087..fcbb5279dbf0dce48d39628e5a778ba4543cd186 100644 --- a/src/app/oauth/services/user-information.service.ts +++ b/src/app/oauth/services/user-information.service.ts @@ -22,7 +22,7 @@ export class UserInformationService { return this.getUser().pipe( map(x => { if (x.roles.length != 0) { - return x.roles.map(y => y.name); + return x.roles.map(y => y.name.toUpperCase()); } else { return ["CITIZEN"]; } diff --git a/src/assets/config.json b/src/assets/config.json index 2e0a1222fe7a383e0ee377603fd8be68cf46e930..01567875b204a27ea1409630ca76bf7939493a49 100644 --- a/src/assets/config.json +++ b/src/assets/config.json @@ -1,6 +1,7 @@ { "idmBaseURL":"http://192.168.99.100:3000", + "dashboardBaseURL":"http://localhost:4200", "client_id":"d3f0bbb0-6846-446a-bce4-2755ad9adcd2", - "client_secret":"", + "client_secret":"59625d70-a36b-40e7-a927-314b1346c3bb", "external-application-cards":[ { "url": "http://217.172.12.141:8080",