OAuth2 client libraries expect error messages to be under the hashtag in the URI. This is a valid response from the OAuth2 server when a user denies access to a client:
This is an issue in the OAuth2\Response class in the setRedirect function which assigns the error messages to the request parameters. The proper way to resolve this would be to extend the OAuth2\Response class and override the setRedirect function. However, api-tools-oauth2 uses static namespaces for Response and Request classes for the OAuth2 namespace.
Therefore there is no method available to set a custom Request or Response class for OAuth2. Overriding these classes is built into OAuth2 by design. But to restate, this repository does not allow for custom classes for Request and Response.
Feature Request
Summary
OAuth2 client libraries expect error messages to be under the hashtag in the URI. This is a valid response from the OAuth2 server when a user denies access to a client:
However the OAuth2 library formats errors as Request parameters such as
Detail
This is an issue in the
OAuth2\Response
class in thesetRedirect
function which assigns the error messages to the request parameters. The proper way to resolve this would be to extend theOAuth2\Response
class and override thesetRedirect
function. However,api-tools-oauth2
uses static namespaces for Response and Request classes for the OAuth2 namespace.Therefore there is no method available to set a custom Request or Response class for OAuth2. Overriding these classes is built into OAuth2 by design. But to restate, this repository does not allow for custom classes for Request and Response.
The Request class takes parameters https://github.com/laminas-api-tools/api-tools-oauth2/blob/1.7.x/src/Controller/AuthController.php#L314 and the Response class does not. But to fix this I think the same method needs to be applied to each.
Proposed Solution
I propose the
api-tools-oauth2
configuration be extended to include two required keys which default to the following:The Auth controller will be modified to use these values instead of the static namespaces used now. These values will be added to https://github.com/laminas-api-tools/api-tools-oauth2/blob/1.7.x/config/module.config.php