feat(fastmcp,mcp): expose fail_closed through the adapter auth factories - #21
Open
RobertoIskandarani wants to merge 3 commits into
Open
feat(fastmcp,mcp): expose fail_closed through the adapter auth factories#21RobertoIskandarani wants to merge 3 commits into
RobertoIskandarani wants to merge 3 commits into
Conversation
The core SDK already implements fail_closed on AuthplaneClient.resource(...), but neither authplane_auth() nor authplane_mcp_auth() forwarded it, so factory users opting into revocation checking were locked into fail-open behavior on introspection/revocation-check outages. Both factories now accept fail_closed: bool = False and pass it through at the client.resource(...) boundary. The default preserves today's fail-open behavior. Also adds the previously missing core coverage for fail_closed=True (crashing custom checker and introspection HTTP 500 both reject with TokenRevokedError), forwarding tests for both adapters, and user-guide docs covering the availability/security trade-off, the authenticated-introspection credential requirement, and the circuit-breaker interaction. Requested in #20.
ruff 0.16.0 started formatting Python code blocks inside Markdown files, so CI (which installs the latest ruff satisfying >=0.8) rejects the previously formatted docs. Blank-line normalization only, no content changes.
RobertoIskandarani
force-pushed
the
feat/fastmcp-fail-closed
branch
from
July 28, 2026 19:23
b6a4e4b to
0520af7
Compare
…ases - AuthplaneClient.resource() logs a warning when fail_closed=True is combined with revocation_checker=None. The flag is a security-relevant no-op in that combination, and the misconfiguration should be observable in production, not only documented. The warning lives in the core factory rather than the adapters so direct resource() users get it too. - New core tests pin two fail-closed failure modes that were emergent: AS metadata without introspection_endpoint rejects every token (permanently, since it is a configuration property rather than an outage), and an open circuit breaker rejects all traffic without further HTTP calls (TokenRevokedError with CircuitOpenError as cause). - Both user guides gain the metadata trade-off bullet and note the new warning.
RobertoIskandarani
force-pushed
the
feat/fastmcp-fail-closed
branch
from
July 28, 2026 19:51
40ee361 to
f0442bd
Compare
muralx
approved these changes
Jul 29, 2026
muralx
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, please pin ruff version so we avoid formatting changes from happening during feature development and bug fixes.
| ## [Unreleased] | ||
|
|
||
| ### Added | ||
| - `authplane-fastmcp`, `authplane-mcp`: `authplane_auth()` and `authplane_mcp_auth()` accept `fail_closed: bool = False` and forward it to `AuthplaneClient.resource(...)`, so factory users can opt into rejecting tokens (`TokenRevokedError`) when the configured `revocation_checker` itself fails — e.g. an unreachable introspection endpoint — instead of the default fail-open acceptance. The flag is only consulted when a `revocation_checker` is configured; `AuthplaneClient.resource(...)` now logs a warning when `fail_closed=True` is set without one, since that combination runs no revocation check at all. Both user guides document the availability/security trade-off, the authenticated-introspection credential requirement, the circuit-breaker interaction, and the permanent rejection that results from AS metadata lacking `introspection_endpoint`. |
Collaborator
There was a problem hiding this comment.
Keep changelog short, documentation is in the code, and in the Issue.
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.
Closes #20.
What
Both adapter factories —
authplane_fastmcp.authplane_auth()andauthplane_mcp.authplane_mcp_auth()— now acceptfail_closed: bool = Falseand forward it toAuthplaneClient.resource(...). The core SDK already implementedfail_closed; the factories simply never exposed it, so integrations opting intoIntrospectionRevocation()were locked into fail-open behavior on introspection/revocation-check outages unless they abandoned the one-call factory and wired the resource manually.authplane-mcphad the same gap asauthplane-fastmcp, so both factories are covered in this PR to keep them in parity with the core API.Changes
fail_closed: bool = Falsekeyword on both factories, forwarded at theclient.resource(...)boundary. Default preserves today's fail-open behavior; fully backward compatible.fail_closed=True(previously untested): a crashing custom checker and an introspection HTTP 500 both reject withTokenRevokedError.False, explicitTrue).revocation_checker.Testing
pytest tests(core): 522 passedpytest testsinauthplane-fastmcp: 55 passedpytest testsinauthplane-mcp: 55 passedruff check/ruff format --check: cleanpyright: 0 errors