Files
chainlit--chainlit/cypress/e2e/header_auth/main.py
T
wehub-resource-sync b7f52be4c9
CI / Run CI (push) Has been cancelled
CI / check-backend (push) Has been cancelled
CI / check-frontend (push) Has been cancelled
CI / tests (push) Has been cancelled
CI / e2e-tests (push) Has been cancelled
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:48:47 +08:00

21 lines
467 B
Python

import os
from typing import Optional
import chainlit as cl
os.environ["CHAINLIT_AUTH_SECRET"] = "SUPER_SECRET" # nosec B105
@cl.header_auth_callback
async def header_auth_callback(headers) -> Optional[cl.User]:
if headers.get("test-header"):
return cl.User(identifier="admin")
else:
return None
@cl.on_chat_start
async def on_chat_start():
user = cl.user_session.get("user")
await cl.Message(f"Hello {user.identifier}").send()