Repository navigation
Flask: plugins (JWT/API-key auth), enable_cors, publish_swagger, openapi_insecure - #45
Merged
Merged
Conversation
…er, openapi_insecure (#42) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…require AuthPlugin (review fixes) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Fixes #42 (the auth/CORS/swagger part; the leftovers from the #43 review are now #44).
JWTPlugin/ApiKeyAuthPlugingain a framework-independentauthenticate(header, *, method, endpoint)(reusingpy2http.auth); the Bottle plugins now call it, behaviour unchanged.py2http/flask_plugins.py:before_requestauth hook (plugins run outermost-first as under Bottle;/pingpublic;/openapipublic iffopenapi_insecure— note the issue text had this inverted, Bottle's code is followed; unmatched routes run no view; with CORS the OPTIONS preflight is open, as Bottle's CORS plugin answers before auth),after_requestCORS headers, claims onrequest.token(reachable throughcurrent_request).authenticate(Bottle-only) still raisesNotImplementedError: never silently dropped.publish_swaggerviaswagger_ui.api_doc(Flask supported); guarded by the plugins like any route (as under Bottle).test_flask_plugins.py): 295 passed (271 before).Auth is security-sensitive. Adversarial review (fresh Opus, security): round 1 found a MEDIUM bypass (ping/openapi exempted by endpoint name, so a user function named
openapiwithopenapi_insecurewas public under Flask) and a LOW (duck-typedauthenticate). Both fixed (exemption by view-function identity; plugins must subclasspy2http.auth.AuthPlugin) with regression tests. Round 2 on the fixed state: PASS, no bypass, Bottle behaviour identical to master across the request matrix. Tests: 297 passed.🤖 Generated with Claude Code