mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-28 04:49:21 +02:00
Add support for overridding scopes for OIDC (#3759)
This commit is contained in:
@@ -4,6 +4,20 @@ import os
|
|||||||
# Applicable for OIDC Auth
|
# Applicable for OIDC Auth
|
||||||
OPENID_CONFIG_URL = os.environ.get("OPENID_CONFIG_URL", "")
|
OPENID_CONFIG_URL = os.environ.get("OPENID_CONFIG_URL", "")
|
||||||
|
|
||||||
|
# Applicable for OIDC Auth, allows you to override the scopes that
|
||||||
|
# are requested from the OIDC provider. Currently used when passing
|
||||||
|
# over access tokens to tool calls and the tool needs more scopes
|
||||||
|
OIDC_SCOPE_OVERRIDE: list[str] | None = None
|
||||||
|
_OIDC_SCOPE_OVERRIDE = os.environ.get("OIDC_SCOPE_OVERRIDE")
|
||||||
|
|
||||||
|
if _OIDC_SCOPE_OVERRIDE:
|
||||||
|
try:
|
||||||
|
OIDC_SCOPE_OVERRIDE = [
|
||||||
|
scope.strip() for scope in _OIDC_SCOPE_OVERRIDE.split(",")
|
||||||
|
]
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# Applicable for SAML Auth
|
# Applicable for SAML Auth
|
||||||
SAML_CONF_DIR = os.environ.get("SAML_CONF_DIR") or "/app/ee/onyx/configs/saml_config"
|
SAML_CONF_DIR = os.environ.get("SAML_CONF_DIR") or "/app/ee/onyx/configs/saml_config"
|
||||||
|
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from httpx_oauth.clients.google import GoogleOAuth2
|
from httpx_oauth.clients.google import GoogleOAuth2
|
||||||
|
from httpx_oauth.clients.openid import BASE_SCOPES
|
||||||
from httpx_oauth.clients.openid import OpenID
|
from httpx_oauth.clients.openid import OpenID
|
||||||
|
|
||||||
|
from ee.onyx.configs.app_configs import OIDC_SCOPE_OVERRIDE
|
||||||
from ee.onyx.configs.app_configs import OPENID_CONFIG_URL
|
from ee.onyx.configs.app_configs import OPENID_CONFIG_URL
|
||||||
from ee.onyx.server.analytics.api import router as analytics_router
|
from ee.onyx.server.analytics.api import router as analytics_router
|
||||||
from ee.onyx.server.auth_check import check_ee_router_auth
|
from ee.onyx.server.auth_check import check_ee_router_auth
|
||||||
@@ -88,7 +90,13 @@ def get_application() -> FastAPI:
|
|||||||
include_auth_router_with_prefix(
|
include_auth_router_with_prefix(
|
||||||
application,
|
application,
|
||||||
create_onyx_oauth_router(
|
create_onyx_oauth_router(
|
||||||
OpenID(OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET, OPENID_CONFIG_URL),
|
OpenID(
|
||||||
|
OAUTH_CLIENT_ID,
|
||||||
|
OAUTH_CLIENT_SECRET,
|
||||||
|
OPENID_CONFIG_URL,
|
||||||
|
# BASE_SCOPES is the same as not setting this
|
||||||
|
base_scopes=OIDC_SCOPE_OVERRIDE or BASE_SCOPES,
|
||||||
|
),
|
||||||
auth_backend,
|
auth_backend,
|
||||||
USER_AUTH_SECRET,
|
USER_AUTH_SECRET,
|
||||||
associate_by_email=True,
|
associate_by_email=True,
|
||||||
|
Reference in New Issue
Block a user