Skip to content

feat(auth): normalize /v1 to Bearer; accept x-api-key/Basic/raw as aliases#32

Draft
grahama1970 wants to merge 2 commits intochutesai:mainfrom
grahama1970:feature/openai-bearer-auth
Draft

feat(auth): normalize /v1 to Bearer; accept x-api-key/Basic/raw as aliases#32
grahama1970 wants to merge 2 commits intochutesai:mainfrom
grahama1970:feature/openai-bearer-auth

Conversation

@grahama1970
Copy link

Summary

Standardize authentication for all OpenAI-compatible /v1 endpoints so clients can use a single canonical header.

  • Canonical: Authorization: Bearer <token>
  • Server-side aliases accepted: x-api-key, Authorization: Basic, raw Authorization

Changes

  • New middleware chutes/middleware/auth_normalization.py normalizes headers on /v1/*.
  • Unit tests in tests/test_auth_normalization.py cover Bearer passthrough, alias normalization, and non-/v1 behavior.
  • README: added an OpenAI-compatible section showing Bearer usage.

Notes

  • Management/signed endpoints (non-/v1) unchanged.
  • If desired, middleware can be guarded by an env toggle in a follow-up.

@grahama1970
Copy link
Author

Added CHUTES_CANONICALIZE_OPENAI_AUTH env toggle; marked bypass test xfail due to Starlette TestClient init timing. Normalization tests pass. Ready for review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments