c896a2de63
Implement dual OAuth flows for Progressive Consent architecture: Flow 1 (Client Authentication): - Client authenticates directly to IdP with its own client_id - Server validates client_id against ALLOWED_MCP_CLIENTS whitelist - Issues tokens with aud: "mcp-server" for MCP authentication only - Progressive mode detected via ENABLE_PROGRESSIVE_CONSENT env var Flow 2 (Resource Provisioning): - New endpoints: /oauth/authorize-nextcloud, /oauth/callback-nextcloud - MCP server acts as OAuth client for delegated Nextcloud access - Stores master refresh tokens with flow_type and audience metadata - Returns success HTML page after provisioning completion Scope Authorization Updates: - Added ProvisioningRequiredError for missing Flow 2 provisioning - Decorator checks if Nextcloud scopes require provisioning in Progressive mode - Validates token has Nextcloud scopes before allowing access Storage Schema Enhancements: - Added flow_type, is_provisioning, requested_scopes to oauth_sessions - Enhanced store_oauth_session to support Progressive Consent metadata - Maintains backward compatibility with hybrid flow This completes the Progressive Consent implementation, enabling: - Explicit user consent for resource access - Stateless server by default (no automatic provisioning) - Clear separation between authentication and resource access - Defense in depth with audience-specific tokens 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>