Add bearer token authentication support to DEEPaaS API#198
Draft
Copilot wants to merge 39 commits intov3-fastapifrom
Draft
Add bearer token authentication support to DEEPaaS API#198Copilot wants to merge 39 commits intov3-fastapifrom
Copilot wants to merge 39 commits intov3-fastapifrom
Conversation
This requires that we change all model args/responses from Marshmallow to Pydantic. Most of the code is in this change, we can split it later on two different changes (marshmallow + pydantic and FastAPI for predict).
After checking with people using the package for a while, the training methods were not used at all, therefore we are now removing the training endpoints. This also allows us to have a much more simple codebase.
…lementation Co-authored-by: alvarolopez <468751+alvarolopez@users.noreply.github.com>
Co-authored-by: alvarolopez <468751+alvarolopez@users.noreply.github.com>
Co-authored-by: alvarolopez <468751+alvarolopez@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for bearer authentication
Add bearer token authentication support to DEEPaaS API
Sep 26, 2025
alvarolopez
requested changes
Sep 26, 2025
Collaborator
alvarolopez
left a comment
There was a problem hiding this comment.
@copilot please address the changes, and take into account that we use rST for docs.
| ) -> str: | ||
| """Verify the bearer token against the configured token. | ||
|
|
||
| Args: |
… to reStructuredText Co-authored-by: alvarolopez <468751+alvarolopez@users.noreply.github.com>
Author
Addressed both changes:
The documentation is now properly integrated into the Sphinx documentation structure and follows project conventions. Commit 288b790. |
|
f0df6de to
471eb1a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This PR implements bearer token authentication for DEEPaaS API endpoints to address cases where fine-grained authentication is not needed but API access control is required.
Overview
The implementation adds optional bearer token authentication that can be enabled via configuration. When enabled, protected endpoints require a valid
Authorization: Bearer <token>header. The feature is backward compatible - authentication is disabled by default and existing deployments continue to work unchanged.Key Features
🔐 Security Implementation
HTTPBearersecurity scheme following RFC 6750 standards/v2/models/) and predict endpoints (/v2/models/{model}/predict)/and version/v2/) remain accessible without authenticationWWW-Authenticate: Bearerheaders for unauthorized requests⚙️ Configuration
The bearer token is configured via the new
--auth-bearer-tokenoption:🔌 API Usage
When authentication is enabled, API clients must include the bearer token:
Implementation Details
New Files
deepaas/auth.py- Authentication module with token validation logic (using Sphinx docstring format)deepaas/tests/test_auth.py- Unit tests for authentication functionalitydeepaas/tests/test_e2e_auth.py- End-to-end API integration testsdoc/source/user/authentication.rst- Documentation with usage examples and security considerations (reStructuredText format)Modified Files
deepaas/config.py- Addedauth_bearer_tokenconfiguration option (marked as secret)deepaas/api/v2/models.py- Added authentication dependency to model endpointsdeepaas/api/v2/predict.py- Added authentication dependency to predict endpointsdoc/source/user/index.rst- Added authentication documentation to user documentation indexBehavioral Changes
auth_bearer_tokenis not set (default): All endpoints work as before - no authentication requiredauth_bearer_tokenis set: Model and predict endpoints require valid bearer token, other endpoints remain publicTesting
Added comprehensive test coverage with 18 new tests:
Security Considerations
This implementation provides a simple but effective authentication mechanism for deployments that need basic API access control without the complexity of fine-grained authorization systems.
Fixes #151
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.