mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 11:57:51 +01:00
rewrite oauth role management logic to allow any custom roles to be used for oauth role to open webui role mapping
This commit is contained in:
@@ -394,10 +394,10 @@ OAUTH_EMAIL_CLAIM = PersistentConfig(
|
||||
os.environ.get("OAUTH_EMAIL_CLAIM", "email"),
|
||||
)
|
||||
|
||||
ENABLE_OAUTH_ROLE_MAPPING = PersistentConfig(
|
||||
"ENABLE_OAUTH_ROLE_MAPPING",
|
||||
ENABLE_OAUTH_ROLE_MANAGEMENT = PersistentConfig(
|
||||
"ENABLE_OAUTH_ROLE_MANAGEMENT",
|
||||
"oauth.enable_role_mapping",
|
||||
os.environ.get("ENABLE_OAUTH_ROLE_MAPPING", "False").lower() == "true",
|
||||
os.environ.get("ENABLE_OAUTH_ROLE_MANAGEMENT", "False").lower() == "true",
|
||||
)
|
||||
|
||||
OAUTH_ROLES_CLAIM = PersistentConfig(
|
||||
@@ -406,6 +406,17 @@ OAUTH_ROLES_CLAIM = PersistentConfig(
|
||||
os.environ.get("OAUTH_ROLES_CLAIM", "roles"),
|
||||
)
|
||||
|
||||
OAUTH_ALLOWED_ROLES = PersistentConfig(
|
||||
"OAUTH_ALLOWED_ROLES",
|
||||
"oauth.allowed_roles",
|
||||
[role.strip() for role in os.environ.get("OAUTH_ALLOWED_ROLES", "pending,user,admin").split(",")],
|
||||
)
|
||||
|
||||
OAUTH_ADMIN_ROLES = PersistentConfig(
|
||||
"OAUTH_ADMIN_ROLES",
|
||||
"oauth.admin_roles",
|
||||
[role.strip() for role in os.environ.get("OAUTH_ADMIN_ROLES", "admin").split(",")],
|
||||
)
|
||||
|
||||
def load_oauth_providers():
|
||||
OAUTH_PROVIDERS.clear()
|
||||
|
||||
Reference in New Issue
Block a user