Skip to content

Commit

Permalink
fix: remove default idpFilter
Browse files Browse the repository at this point in the history
* removing default idpFilter from defaulConfig of user profile and admin
gui
  • Loading branch information
xkureck committed Aug 4, 2021
1 parent 2790977 commit b36088f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
7 changes: 1 addition & 6 deletions apps/admin-gui/src/assets/config/defaultConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 1 addition & 6 deletions apps/user-profile/src/assets/config/defaultConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
45 changes: 26 additions & 19 deletions libs/perun/services/src/lib/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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;
}
Expand Down

0 comments on commit b36088f

Please sign in to comment.