Skip to content

Conversation

@Roman505050
Copy link

Applicable issues

Description of changes

This pull request improves authentication handling in the FromRequestDeploymentMixin class by integrating FastAPI's HTTPBearer authentication scheme. Key updates include:

  • aidial_sdk/deployment/from_request_mixin.py: Imported HTTPBearer from FastAPI to support bearer token authentication.
  • aidial_sdk/deployment/from_request_mixin.py: Introduced a _bearer class attribute initialized with HTTPBearer(auto_error=False) to enable optional error raising on missing/invalid tokens.
  • aidial_sdk/deployment/from_request_mixin.py: Refactored the from_request method to use _bearer for token extraction. The method now processes the Authorization header using _bearer and extracts the token from the resulting credentials.

These changes address an issue where the JWT token was not correctly retrieved from the Authorization: Bearer header.

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Roman505050 Roman505050 requested a review from vladisavvv as a code owner April 17, 2025 20:03
@Roman505050 Roman505050 changed the title refactor(auth): use FastAPI's HTTPBearer for JWT token extraction chore(auth): use FastAPI's HTTPBearer for JWT token extraction Apr 17, 2025
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.

jwt field of the request doesn't contain JWT, but Bearer: JWT

1 participant