Skip to content

fix(auth): expose cookie OAuth model for OpenAPI - #2968

Open
gaoflow wants to merge 2 commits into
Chainlit:mainfrom
gaoflow:fix-2961-cookie-oauth-openapi-model
Open

fix(auth): expose cookie OAuth model for OpenAPI#2968
gaoflow wants to merge 2 commits into
Chainlit:mainfrom
gaoflow:fix-2961-cookie-oauth-openapi-model

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 19, 2026

Copy link
Copy Markdown

Summary

  • Expose the OAuth2 OpenAPI model on OAuth2PasswordBearerWithCookie so FastAPI can emit a security scheme for it.
  • Routes that use the cookie OAuth dependency currently make OpenAPI generation raise AttributeError, because the class (unlike the built-in OAuth2PasswordBearer) never set self.model.
  • Added a test that generates the schema for a Depends(auth_scheme) route and asserts the password-flow security scheme is present.

Tests

  • uv run --all-packages --all-extras --dev pytest backend/tests/auth/test_cookie.py -q
  • uv run --all-packages --all-extras --dev pytest backend/tests/auth backend/tests/test_callbacks.py -q
  • uv run pytest --cov=chainlit from backend/
  • uv run scripts/lint.py
  • uv run scripts/format.py --check
  • uv run scripts/type_check.py

AI assistance was used under my direction.

Co-Authored-By: Codex <noreply@openai.com>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. auth Pertaining to authentication. backend Pertains to the Python backend. unit-tests Has unit tests. labels Jun 19, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@dokterbob

Copy link
Copy Markdown
Collaborator

@codex review

@dokterbob

Copy link
Copy Markdown
Collaborator

@gaoflow #2961 doesn't exist and I am missing a rationale; what problem does this PR solve, e.g. what use cases does it enable?

@gaoflow

gaoflow commented Jul 31, 2026

Copy link
Copy Markdown
Author

This fixes a crash in OpenAPI generation: routes that use OAuth2PasswordBearerWithCookie make get_openapi() raise AttributeError, because unlike the built-in OAuth2PasswordBearer the class never set self.model (the OpenAPI security scheme). The PR sets the OAuth2 password-flow model and adds a schema-generation test. I also corrected the body — the #2961 reference was wrong; it isn't tied to an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Pertaining to authentication. backend Pertains to the Python backend. size:XS This PR changes 0-9 lines, ignoring generated files. unit-tests Has unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants