Skip to content

Commit

Permalink
Update roles mapping with new roles and append the org role (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luiggi370z authored Jan 2, 2024
1 parent df67298 commit 395730e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions custom_sso_security_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ def oauth_user_info(self, provider, response=None): # type: ignore

logger.debug("Auth0 user_data: %s", me)

email = me["email"]

organization: str = me["organization"] if "organization" in me else None

superset_roles: list[str] = me["role_keys"] if "role_keys" in me else []

if organization is not None and len(organization) > 0:
superset_roles.append(organization.capitalize())
else:
logger.error(f"User ${email} does not have an organization.")

given_name = (
me["given_name"]
if "given_name" in me
Expand All @@ -44,9 +55,8 @@ def oauth_user_info(self, provider, response=None): # type: ignore
return {
"username": me["email"],
"name": me["name"],
"email": me["email"],
"email": email,
"first_name": given_name,
"last_name": family_name,
"role_keys": me["role_keys"] if "role_keys" in me else [],
# "organization": me["organization"],
"role_keys": superset_roles,
}
4 changes: 2 additions & 2 deletions superset_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@

# Roles mapping with OAuth roles_key claim
AUTH_ROLES_MAPPING = {
"superset_super_users": ["Gamma", "Alpha"],
"superset_users": ["Account"],
"superset_super_users": ["Standard User", "Super User", "sql_lab"],
"superset_users": ["Standard User"],
"superset_admins": ["Admin"],
}

Expand Down

0 comments on commit 395730e

Please sign in to comment.