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

Fix pkce auth with auth header #395

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.1]

### Changed

- Fix unnecessary client_id in token params. Which can issue errors in OIDC providers authentication with PKCE support. Fixes [issue](https://github.com/jumbojett/OpenID-Connect-PHP/issues/312)
- Remove type hints for `getAccessToken`, `getRefreshToken`, `getIdToken` because when calling this method, in case the OIDC provider did not send these tokens to the application, may cause error in application, since variables `accessToken`, `refreshToken`, `idToken` still null

## [1.0.0] - 2023-12-13

### Added
Expand Down
26 changes: 18 additions & 8 deletions src/OpenIDConnectClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,10 +918,8 @@ protected function requestTokens(string $code, array $headers = []) {
$authorizationHeader = null;
unset($token_params['client_secret']);
}
$token_params = array_merge($token_params, [
'client_id' => $this->clientID,
'code_verifier' => $this->getCodeVerifier()
]);

$token_params['code_verifier'] = $this->getCodeVerifier();
}

// Convert token params to string format
Expand Down Expand Up @@ -1717,22 +1715,34 @@ public function getClientSecret() {
* Set the access token.
*
* May be required for subclasses of this Client.
*
* @param string|null $accessToken
*/
public function setAccessToken(string $accessToken) {
public function setAccessToken($accessToken) {
$this->accessToken = $accessToken;
}

public function getAccessToken(): string

/**
* @return string|null
*/
public function getAccessToken()
{
return $this->accessToken;
}

public function getRefreshToken(): string
/**
* @return string|null
*/
public function getRefreshToken()
{
return $this->refreshToken;
}

public function getIdToken(): string
/**
* @return string|null
*/
public function getIdToken()
{
return $this->idToken;
}
Expand Down