mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
feat: add OAUTH_ROLES_SEPARATOR env var
This allows changing the separator for the `OAUTH_ALLOWED_ROLES` and `OAUTH_ADMIN_ROLES` env vars, from the default comma (,) to something that is not present in the role name. The intended audience is folks with LDAP-syntax groups/roles, e.g. `cn=webui_admin,ou=it_department,o=my_org` instead of just `webui_admin`.
This commit is contained in:
parent
7a83e7dfa3
commit
35504e8486
1 changed files with 4 additions and 2 deletions
|
|
@ -576,19 +576,21 @@ OAUTH_ROLES_CLAIM = PersistentConfig(
|
||||||
os.environ.get("OAUTH_ROLES_CLAIM", "roles"),
|
os.environ.get("OAUTH_ROLES_CLAIM", "roles"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SEP = os.environ.get("OAUTH_ROLES_SEPARATOR", ",")
|
||||||
|
|
||||||
OAUTH_ALLOWED_ROLES = PersistentConfig(
|
OAUTH_ALLOWED_ROLES = PersistentConfig(
|
||||||
"OAUTH_ALLOWED_ROLES",
|
"OAUTH_ALLOWED_ROLES",
|
||||||
"oauth.allowed_roles",
|
"oauth.allowed_roles",
|
||||||
[
|
[
|
||||||
role.strip()
|
role.strip()
|
||||||
for role in os.environ.get("OAUTH_ALLOWED_ROLES", "user,admin").split(",")
|
for role in os.environ.get("OAUTH_ALLOWED_ROLES", f"user{SEP}admin").split(SEP)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
OAUTH_ADMIN_ROLES = PersistentConfig(
|
OAUTH_ADMIN_ROLES = PersistentConfig(
|
||||||
"OAUTH_ADMIN_ROLES",
|
"OAUTH_ADMIN_ROLES",
|
||||||
"oauth.admin_roles",
|
"oauth.admin_roles",
|
||||||
[role.strip() for role in os.environ.get("OAUTH_ADMIN_ROLES", "admin").split(",")],
|
[role.strip() for role in os.environ.get("OAUTH_ADMIN_ROLES", "admin").split(SEP)],
|
||||||
)
|
)
|
||||||
|
|
||||||
OAUTH_ALLOWED_DOMAINS = PersistentConfig(
|
OAUTH_ALLOWED_DOMAINS = PersistentConfig(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue