Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth2 client api() call sends access Token via HTTP vars instead of Authorization Bearer Header #386

Closed
ldkafka opened this issue Feb 23, 2024 · 3 comments

Comments

@ldkafka
Copy link

ldkafka commented Feb 23, 2024

Latest Yii2 version, in yii2-authclient/src
/OAuth2.php, Line 171

public function applyAccessTokenToRequest($request, $accessToken)
{
    $data = $request->getData();
    $data['access_token'] = $accessToken->getToken();
    $request->setData($data);
}

This is called from a BaseOAuth event in beforeApiRequestSend

The applyAccessTokenToRequest should either default to use Bearer Header Tokens, or be configurable like the the Server REST/Oauth2 implementations are configured with Authorization behaviour filters (of course using a method/attribute not filters).

Since most Oauth2/REST servers require Authorization Bearer Headers, how did this implementation ever work, or am I missing something?

@samdark samdark transferred this issue from yiisoft/yii2 Feb 23, 2024
@samdark
Copy link
Member

samdark commented Feb 23, 2024

@samdark samdark closed this as completed Feb 23, 2024
@rhertogh
Copy link
Contributor

I think the default Oauth2 client should (have at least the option to) set the Authorization header.
According to the The OAuth 2.0 Authorization Framework RFC in the chapter Accessing Protected Resources:

The method in which the client utilizes the access token to authenticate with the resource server depends on the type of access token issued by the authorization server. Typically, it involves using the HTTP "Authorization" request header field ...

@samdark
Copy link
Member

samdark commented Feb 23, 2024

Yes, maybe. The issue here is that it will break compatibility with clients that do not override the method.

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

No branches or pull requests

3 participants