Skip to content

Feature/mcp oauth layer#115

Draft
MathieuLamiot wants to merge 6 commits into
developfrom
feature/mcp-oauth-layer
Draft

Feature/mcp oauth layer#115
MathieuLamiot wants to merge 6 commits into
developfrom
feature/mcp-oauth-layer

Conversation

@MathieuLamiot

Copy link
Copy Markdown
Owner

Description

Fixes:

  • link to issue

Explain how this code impacts users.

Type of change

  • New feature (non-breaking change which adds functionality).
  • Bug fix (non-breaking change which fixes an issue).
  • Enhancement (non-breaking change which improves an existing functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as before).
  • Sub-task of #(issue number)
  • Chore
  • Release

Detailed scenario

What was tested

Describe the scenarios that you tested, and specify if it is automated or manual. For manual scenarios, provide a screenshot of the results.

How to test

Describe how the PR can be tested so that the validator can be autonomous: environment, dependencies, specific setup, steps to perform, API requests, etc.

Affected Features & Quality Assurance Scope

Please specify which existing features or modules are impacted by the changes in this Pull Request. This information is crucial for the QA team to properly define the testing scope and ensure comprehensive test coverage.

Technical description

Documentation

Explain how this code works. Diagrams & drawings are welcome.

New dependencies

List any new dependencies that are required for this change.

Risks

List possible performance & security issues or risks, and explain how they have been mitigated.

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionable.

Unticked items justification

If some mandatory items are not relevant, explain why in this section.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

MathieuLamiot and others added 6 commits May 25, 2026 09:01
…ords

Adds a self-contained MCP authentication layer (src/MCP/Auth/) that lets
Claude / MCP clients authenticate via short-lived JWTs while Application
Passwords never leave the server.

- SecretManager: generates and rotates the 256-bit HMAC signing secret
- JWT: pure HS256 encode/decode with no external dependencies
- DiscoveryEndpoints: RFC 9728 / RFC 8414 well-known documents
- ClientRegistration: RFC 7591 dynamic client registration (POST /oauth/register)
- AuthorizeEndpoint: PKCE S256 authorization request (GET /oauth/authorize)
- AuthorizeCallback: post-login code issuance (GET /oauth/authorize-callback)
- TokenEndpoint: authorization_code + refresh_token grants (POST /oauth/token)
- RequestValidator: Bearer JWT middleware for MCP REST routes
- AdminPage: MCP Sessions settings page with per-session and bulk revocation
- McpAuth: single bootstrap entry point wired into class-sybgo.php

All classes namespaced under Sybgo\MCP\Auth with a README documenting
extraction steps for use in other plugins.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ogging

- Add Mcp_Logger class: structured [MCP][SCOPE] logging with header/body
  redaction across all OAuth and MCP request handlers
- Fix RequestValidator: call wp_set_current_user() before returning WP_User
  so HttpSessionValidator::create_session() gets the correct user ID
- Fix Ability_Manager: bind registration to wp_abilities_api_categories_init
  and wp_abilities_api_init (WP 6.9 enforces these; calling outside the hooks
  silently drops the ability)
- Fix AI_Module + Event_Module: register abilities into the cache in boot()
  rather than on init@5, so the cache is populated before wp_abilities_api_init
  fires
- Add McpAuth: rest_pre_dispatch returns 401 + WWW-Authenticate for
  unauthenticated MCP requests; rest_post_dispatch logs final response

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n fixes

Documents the full hook sequence, why abilities must be registered in boot()
rather than init@5, wp_set_current_user() requirement, and all past failures
with their root causes and fixes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…_DEBUG

Add Mcp_Logger::is_debug_enabled() and a $debug_only parameter to log().
Happy-path traces (per-request header dumps, per-ability registration details,
rest_pre_dispatch on success, rest_post_dispatch on success) are now silent in
production and fire only when WP_DEBUG or SYBGO_MCP_DEBUG is true.
Auth failures, JWT rejections, and JSON-RPC errors always log regardless.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Self-standing HTML reference covering the full OAuth 2.1 + PKCE JWT façade:
flow steps, class map, three bypasses, WP Abilities API hook timing rules,
JWT lifecycle, debug guide, known pitfalls, and four open questions with
suggestions for the team to follow-up on.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant