Skip to content

Commit

Permalink
modify domain to allow all abandon auth domains, add debug version of…
Browse files Browse the repository at this point in the history
… cookie response
  • Loading branch information
fisher60 committed Jun 19, 2024
1 parent 65e2d73 commit 3310306
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/api/abandonauth/routers/ui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from urllib.parse import urlparse

import httpx
from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import RedirectResponse
Expand All @@ -14,6 +16,9 @@
BASE_URL = "http://localhost"


COOKIE_DOMAIN_URL = "." + urlparse(settings.ABANDON_AUTH_SITE_URL).netloc


@router.get("/", include_in_schema=False)
async def index(request: Request, code: str | None = None) -> RedirectResponse:
"""Developer landing page for AbandonAuth UI."""
Expand Down Expand Up @@ -47,12 +52,19 @@ async def index(request: Request, code: str | None = None) -> RedirectResponse:
if authenticated is False:
return resp

resp.set_cookie(
key="Authorization",
value=token, # pyright: ignore [reportArgumentType]
domain=settings.ABANDON_AUTH_SITE_URL,
httponly=True
)
if settings.DEBUG:
resp.set_cookie(
key="Authorization",
value=token, # pyright: ignore [reportArgumentType]
)
else:
resp.set_cookie(
key="Authorization",
value=token, # pyright: ignore [reportArgumentType]
domain=COOKIE_DOMAIN_URL,
httponly=True,
secure=True
)

return resp

Expand Down

0 comments on commit 3310306

Please sign in to comment.