fix: Simplify token verifier to be RFC 7519 compliant
Per RFC 7519 Section 4.1.3, resource servers should only validate their own presence in the audience claim, not check for other resource servers. Changes: - UnifiedTokenVerifier now validates only MCP audience (not Nextcloud's) - Nextcloud independently validates its own audience when receiving API calls - This is NOT token passthrough (we validate tokens before use) - This IS token reuse which is explicitly allowed by RFC 8707 Updates: - Simplified _validate_multi_audience() to follow OAuth spec - Updated docstrings and comments to clarify RFC 7519 compliance - Fixed unit tests that expected dual-audience validation - Updated ADR-005 to document the correct OAuth interpretation - All tests pass: unit (65), smoke (5), OAuth integration This makes the implementation simpler, more maintainable, and properly aligned with OAuth 2.0 specifications while maintaining security. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -24,9 +24,9 @@ def get_client_from_context(ctx: Context, base_url: str) -> NextcloudClient:
|
||||
"""
|
||||
Create NextcloudClient for multi-audience mode (no exchange needed).
|
||||
|
||||
ADR-005 Mode 1: Token already contains both MCP and Nextcloud audiences.
|
||||
The UnifiedTokenVerifier validated both audiences are present, so we can
|
||||
use the token directly without exchange.
|
||||
ADR-005 Mode 1: Use multi-audience tokens directly.
|
||||
The UnifiedTokenVerifier validated MCP audience per RFC 7519.
|
||||
Nextcloud will independently validate its own audience.
|
||||
|
||||
Args:
|
||||
ctx: MCP request context containing session info
|
||||
@@ -65,8 +65,8 @@ def get_client_from_context(ctx: Context, base_url: str) -> NextcloudClient:
|
||||
f"(no exchange needed)"
|
||||
)
|
||||
|
||||
# Token was already validated to have both audiences
|
||||
# Can use directly without exchange
|
||||
# Token was validated to have MCP audience
|
||||
# Nextcloud will validate its own audience independently
|
||||
return NextcloudClient.from_token(
|
||||
base_url=base_url, token=access_token.token, username=username
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user