diff --git a/apps/admin-gui/src/assets/config/defaultConfig.json b/apps/admin-gui/src/assets/config/defaultConfig.json index ad61862a6..ce662bd53 100644 --- a/apps/admin-gui/src/assets/config/defaultConfig.json +++ b/apps/admin-gui/src/assets/config/defaultConfig.json @@ -18,12 +18,7 @@ "oauth_silent_redirect_uri": "http://localhost:4200/silent-refresh.html", "oauth_load_user_info": false, "oauth_scopes": "openid profile perun_api perun_admin", - "oauth_response_type": "id_token token", - "filters": { - "default": "urn:cesnet:proxyidp:filter:eyJ2ZXIiOiIyIiwiYWxsb3dGZWVkcyI6eyJlZHVJRC5jeiI6e30sImVkdUdBSU4iOnt9LCJMb2dpbk11bmkiOnt9LCJTb2NpYWxJZFBzIjp7fSwiU3RhbmRhbG9uZUlkUCI6e30sIkhha2EiOnt9fX0=", - "muni": "urn:cesnet:proxyidp:idpentityid:https://idp2.ics.muni.cz/idp/shibboleth", - "soc_idp": "urn:cesnet:proxyidp:filter:eyJ2ZXIiOiIyIiwiYWxsb3dGZWVkcyI6eyJTb2NpYWxJZFBzIjp7fX19" - } + "oauth_response_type": "id_token token" }, "login_namespace_attributes": [ "urn:perun:user:attribute-def:def:login-namespace:einfra", diff --git a/apps/user-profile/src/assets/config/defaultConfig.json b/apps/user-profile/src/assets/config/defaultConfig.json index 0ff677895..c017c94f1 100644 --- a/apps/user-profile/src/assets/config/defaultConfig.json +++ b/apps/user-profile/src/assets/config/defaultConfig.json @@ -12,12 +12,7 @@ "oauth_post_logout_redirect_uri": "", "oauth_redirect_uri": "http://localhost:4200/api-callback", "oauth_scopes": "openid profile perun_api", - "oauth_response_type": "code", - "filters": { - "default": "urn:cesnet:proxyidp:filter:eyJ2ZXIiOiIyIiwiYWxsb3dGZWVkcyI6eyJlZHVJRC5jeiI6e30sImVkdUdBSU4iOnt9LCJMb2dpbk11bmkiOnt9LCJTb2NpYWxJZFBzIjp7fSwiU3RhbmRhbG9uZUlkUCI6e30sIkhha2EiOnt9fX0=", - "muni": "urn:cesnet:proxyidp:idpentityid:https://idp2.ics.muni.cz/idp/shibboleth", - "soc_idp": "urn:cesnet:proxyidp:filter:eyJ2ZXIiOiIyIiwiYWxsb3dGZWVkcyI6eyJTb2NpYWxJZFBzIjp7fX19" - } + "oauth_response_type": "code" }, "password_namespace_attributes": [ "urn:perun:user:attribute-def:def:login-namespace:einfra", diff --git a/libs/perun/services/src/lib/auth.service.ts b/libs/perun/services/src/lib/auth.service.ts index 168a14102..0d3313a46 100644 --- a/libs/perun/services/src/lib/auth.service.ts +++ b/libs/perun/services/src/lib/auth.service.ts @@ -45,24 +45,7 @@ export class AuthService { redirectUrl: string; getClientSettings(): UserManagerSettings { - const queryParams = location.search.substr(1).split('&'); - const filters = this.store.get('oidc_client', 'filters'); - let filterValue = ''; - let f; - queryParams.forEach(param => { - const parsedParam = param.split('=') - if(parsedParam[0]==='idpFilter'){ - f = filters[parsedParam[1]]; - if(f){ - filterValue = f; - this.filterShortname = parsedParam[1]; - } - } - }) - if(!f){ - filterValue = filters['default']; - this.filterShortname = 'default'; - } + const filterValue = this.setIdpFilter(); return { authority: this.store.get('oidc_client', 'oauth_authority'), client_id: this.store.get('oidc_client', 'oauth_client_id'), @@ -74,10 +57,34 @@ export class AuthService { loadUserInfo: this.store.get('oidc_client', 'oauth_load_user_info'), automaticSilentRenew: true, silent_redirect_uri: this.store.get('oidc_client', 'oauth_silent_redirect_uri'), - extraQueryParams: { 'acr_values': filterValue} + extraQueryParams: { 'acr_values': filterValue } }; } + setIdpFilter(): string { + const queryParams = location.search.substr(1).split('&'); + this.filterShortname = null; + const filters = this.store.get('oidc_client', 'filters'); + if (!filters) { + return null; + } + let filterValue = null; + queryParams.forEach(param => { + const parsedParam = param.split('=') + if(parsedParam[0] === 'idpFilter') { + if (filters[parsedParam[1]]) { + this.filterShortname = parsedParam[1]; + filterValue = filters[parsedParam[1]]; + } + } + }) + if(filters['default'] && !filterValue) { + this.filterShortname = 'default'; + return filters['default']; + } + return filterValue; + } + getUserManager(): UserManager { return this.manager; }