Feature/oauth2 client credentials - #79
Merged
Merged
Conversation
Contributor
|
👋 Thanks for your contribution, @NEFORCEO! Please make sure:
Maintainers will review it soon. |
Contributor
Merging this PR will improve performance by 37.97%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_response_req_text_from_json |
213.2 µs | 132.5 µs | +60.87% |
| ⚡ | test_response_repr |
196.4 µs | 130.7 µs | +50.26% |
| ⚡ | test_response_property_access |
194.5 µs | 131.6 µs | +47.76% |
| ⚡ | test_response_json_parsing |
205.6 µs | 140 µs | +46.83% |
| ⚡ | test_response_creation |
201.3 µs | 138.9 µs | +44.86% |
| ⚡ | test_middleware_after_response |
403.1 µs | 354 µs | +13.89% |
| ⚡ | test_response_json_parsing_large_payload |
666.7 µs | 606 µs | +10.02% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feature/oauth2-client-credentials (4bdad3d) with master (6f3d441)1
Footnotes
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.
🚀 Description
Add
OAuth2ClientCredentials— a new authentication class that implements the OAuth2 Client Credentials grant with automatic token refresh. Works per-route via theauthparameter on any decorator and is fully compatible with the existingresolve_authpipeline.🧩 Type of Change
✅ Checklist
🔗 Related Issues
N/A
📸 Additional Context
What was done
fasthttp/auth.pyOAuth2ClientCredentials(token_url, client_id, client_secret, scopes, extra)class_HttpxOAuth2Auth— httpx-compatible auth that fetches the token lazily on first request, caches it, and auto-refreshes 60s before expiryresolve_auth()to handle the new auth typefasthttp/routing.pyBasicAuth | DigestAuth | BearerAuth | OAuth2ClientCredentials | None) inRoute,_RouteDef,_add_route, and all 7 HTTP method decoratorsfasthttp/app.py_add_routeand all 7 HTTP method decoratorsfasthttp/openapi/generator.pyOAuth2ClientCredentialsto OpenAPI security scheme generation — emitsoauth2 / clientCredentialsflow withtokenUrland scopesfasthttp/__init__.pyOAuth2ClientCredentialsDocumentation (
docs/en/anddocs/ru/)tutorial/authentication.md— newOAuth2ClientCredentialssection with example and parameter tabletutorial/openapi/swagger-ui.md— addedOAuth2ClientCredentialsrow to security schemes tableUsage
Testing
All 559 existing tests pass with no regressions.