Skip to content

Commit aaf4a2c

Browse files
committed
🐛 Generic OIDC authentication
1 parent 9ab27e7 commit aaf4a2c

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

backend/trip/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ class Settings(BaseSettings):
1919

2020
REGISTER_ENABLE: bool = True
2121
OIDC_DISCOVERY_URL: str = ""
22-
OIDC_PROTOCOL: str = "https"
2322
OIDC_CLIENT_ID: str = ""
2423
OIDC_CLIENT_SECRET: str = ""
25-
OIDC_HOST: str = ""
2624
OIDC_REDIRECT_URI: str = ""
2725

2826
class Config:

backend/trip/routers/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
async def auth_params() -> AuthParams:
1717
data = {"oidc": None, "register_enabled": settings.REGISTER_ENABLE}
1818

19-
if settings.OIDC_HOST and settings.OIDC_CLIENT_ID and settings.OIDC_CLIENT_SECRET:
19+
if settings.OIDC_CLIENT_ID and settings.OIDC_CLIENT_SECRET:
2020
oidc_config = await get_oidc_config()
2121
auth_endpoint = oidc_config.get("authorization_endpoint")
2222
data["oidc"] = (
@@ -28,7 +28,7 @@ async def auth_params() -> AuthParams:
2828

2929
@router.post("/oidc/login", response_model=Token)
3030
async def oidc_login(session: SessionDep, code: str = Body(..., embed=True)) -> Token:
31-
if not (settings.OIDC_HOST or settings.OIDC_CLIENT_ID or settings.OIDC_CLIENT_SECRET):
31+
if not (settings.OIDC_CLIENT_ID or settings.OIDC_CLIENT_SECRET):
3232
raise HTTPException(status_code=400, detail="Partial OIDC config")
3333

3434
oidc_config = await get_oidc_config()

backend/trip/security.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ async def get_oidc_config():
7171
if OIDC_CONFIG:
7272
return OIDC_CONFIG
7373

74-
discovery_url = f"{settings.OIDC_PROTOCOL}://{settings.OIDC_HOST}/.well-known/openid-configuration"
75-
if settings.OIDC_DISCOVERY_URL:
76-
discovery_url = settings.OIDC_DISCOVERY_URL
74+
discovery_url = settings.OIDC_DISCOVERY_URL
75+
if not discovery_url:
76+
raise HTTPException(status_code=500, detail="OIDC_DISCOVERY_URL not configured")
7777

7878
OIDC_CONFIG = await httpx_get(discovery_url)
7979
return OIDC_CONFIG

0 commit comments

Comments
 (0)