Skip to content

Commit

Permalink
feat: Add ability to ignore roles when logging in with SSO (#534)
Browse files Browse the repository at this point in the history
Closes #533
  • Loading branch information
lebalz authored Oct 25, 2023
1 parent 1a49826 commit d4b64b9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ services:
# - OIDC_SCOPES=openid email profile
# - OIDC_ADMIN_ROLES=admin
# - OIDC_ROLES_ATTRIBUTE=groups
# - OIDC_IGNORE_ROLES=true
depends_on:
- postgres

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ services:
# - OIDC_SCOPES=openid email profile
# - OIDC_ADMIN_ROLES=admin
# - OIDC_ROLES_ATTRIBUTE=groups
# - OIDC_IGNORE_ROLES=true
depends_on:
- postgres

Expand Down
1 change: 1 addition & 0 deletions server/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SECRET_KEY=notsecretkey
# OIDC_SCOPES=openid email profile
# OIDC_ADMIN_ROLES=admin
# OIDC_ROLES_ATTRIBUTE=groups
# OIDC_IGNORE_ROLES=true

## Do not edit this

Expand Down
5 changes: 5 additions & 0 deletions server/api/helpers/users/get-or-create-one-using-oidc.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ module.exports = {

const updateFieldKeys = ['email', 'isAdmin', 'isSso', 'name', 'username'];

if (sails.config.custom.oidcIgnoreRoles) {
// Remove isAdmin from updateFieldKeys
updateFieldKeys.splice(updateFieldKeys.indexOf('isAdmin'), 1);
}

const updateValues = {};
// eslint-disable-next-line no-restricted-syntax
for (const k of updateFieldKeys) {
Expand Down
1 change: 1 addition & 0 deletions server/config/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports.custom = {
oidcScopes: process.env.OIDC_SCOPES || 'openid email profile',
oidcAdminRoles: process.env.OIDC_ADMIN_ROLES ? process.env.OIDC_ADMIN_ROLES.split(',') : [],
oidcRolesAttribute: process.env.OIDC_ROLES_ATTRIBUTE || 'groups',
oidcIgnoreRoles : process.env.OIDC_IGNORE_ROLES || false,

// TODO: move client base url to environment variable?
oidcRedirectUri: `${
Expand Down

0 comments on commit d4b64b9

Please sign in to comment.