The SimpleOauthAuthenticationProvider in simple_oauth module uses Drupal's PathValidator::getUrlIfValidWithoutAccessCheck() to determine if a route has opted out of OAuth authentication via the _oauth_skip_auth option. However, this creates a bug for POST-only routes that require OAuth authentication.
The issue occurs because:
PathValidator::getUrl() (line 123) creates an internal test request using Request::create('/' . $path)Request::create() without a method parameter defaults to GET requestsmatch() method (line 167) throws MethodNotAllowedException for POST-only routes when matched with GETThis affects any POST-only route that requires OAuth authentication, such as the RFC 7662 Token Introspection endpoint (/oauth/introspect), which must only accept POST requests per the specification.
example.endpoint:
path: '/oauth/example'
defaults:
_controller: '\Drupal\example\Controller\ExampleController::handle'
methods: [POST]
requirements:
_access: 'TRUE'
options:
_auth: ['oauth2']
SimpleOauthAuthenticationProvider::applies() at line 143 calls getUrlIfValidWithoutAccessCheck()Modify SimpleOauthAuthenticationProvider::applies() to pass the current request's HTTP method to the PathValidator. This requires either:
Option 1: Extend PathValidatorInterface to accept an optional Request parameter:
public function getUrlIfValidWithoutAccessCheck($path, Request $request = NULL);
None.
Depends on chosen solution:
PathValidatorInterface::getUrlIfValidWithoutAccessCheck() would accept optional Request parameter (backward compatible)None.
Needs review
6.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.