mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-03 19:49:17 +02:00
More logging for SAML endpoints
This commit is contained in:
parent
61b5bd569b
commit
f6547a64a0
@ -76,9 +76,13 @@ async def prepare_from_fastapi_request(request: Request) -> dict[str, Any]:
|
|||||||
if request.client is None:
|
if request.client is None:
|
||||||
raise ValueError("Invalid request for SAML")
|
raise ValueError("Invalid request for SAML")
|
||||||
|
|
||||||
|
# Use X-Forwarded headers if available
|
||||||
|
http_host = request.headers.get("X-Forwarded-Host") or request.client.host
|
||||||
|
server_port = request.headers.get("X-Forwarded-Port") or request.url.port
|
||||||
|
|
||||||
rv: dict[str, Any] = {
|
rv: dict[str, Any] = {
|
||||||
"http_host": request.client.host,
|
"http_host": http_host,
|
||||||
"server_port": request.url.port,
|
"server_port": server_port,
|
||||||
"script_name": request.url.path,
|
"script_name": request.url.path,
|
||||||
"post_data": {},
|
"post_data": {},
|
||||||
"get_data": {},
|
"get_data": {},
|
||||||
@ -126,16 +130,20 @@ async def saml_login_callback(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not auth.is_authenticated():
|
if not auth.is_authenticated():
|
||||||
|
detail = "Access denied. User was not authenticated"
|
||||||
|
logger.error(detail)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
detail="Access denied. User was not Authenticated.",
|
detail=detail,
|
||||||
)
|
)
|
||||||
|
|
||||||
user_email = auth.get_attribute("email")
|
user_email = auth.get_attribute("email")
|
||||||
if not user_email:
|
if not user_email:
|
||||||
|
detail = "SAML is not set up correctly, email attribute must be provided."
|
||||||
|
logger.error(detail)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_403_FORBIDDEN,
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
detail="SAML is not set up correctly, email attribute must be provided.",
|
detail=detail,
|
||||||
)
|
)
|
||||||
|
|
||||||
user_email = user_email[0]
|
user_email = user_email[0]
|
||||||
|
@ -14,6 +14,16 @@ export const POST = async (request: NextRequest) => {
|
|||||||
const response = await fetch(url.toString(), {
|
const response = await fetch(url.toString(), {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: await request.formData(),
|
body: await request.formData(),
|
||||||
|
headers: {
|
||||||
|
"X-Forwarded-Host":
|
||||||
|
request.headers.get("X-Forwarded-Host") ||
|
||||||
|
request.headers.get("host") ||
|
||||||
|
"",
|
||||||
|
"X-Forwarded-Port":
|
||||||
|
request.headers.get("X-Forwarded-Port") ||
|
||||||
|
new URL(request.url).port ||
|
||||||
|
"",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const setCookieHeader = response.headers.get("set-cookie");
|
const setCookieHeader = response.headers.get("set-cookie");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user