Skip to content

Commit

Permalink
Merge pull request #155 from AngryShaDoW/master
Browse files Browse the repository at this point in the history
Add possibility to change enc_type parameter for http_build_query
  • Loading branch information
jumbojett committed Apr 8, 2019
2 parents 249ef9c + 12e1378 commit a8beafb
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/OpenIDConnectClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ class OpenIDConnectClient
*/
private $redirectURL;

private $enc_type = PHP_QUERY_RFC1738;

/**
* @param $provider_url string optional
*
Expand Down Expand Up @@ -422,7 +424,7 @@ public function signOut($accessToken, $redirect) {
'post_logout_redirect_uri' => $redirect);
}

$signout_endpoint .= (strpos($signout_endpoint, '?') === false ? '?' : '&') . http_build_query( $signout_params, null, '&');
$signout_endpoint .= (strpos($signout_endpoint, '?') === false ? '?' : '&') . http_build_query( $signout_params, null, '&', $this->$enc_type);
$this->redirect($signout_endpoint);
}

Expand Down Expand Up @@ -610,7 +612,7 @@ private function requestAuthorization() {
$auth_params = array_merge($auth_params, array('response_type' => implode(' ', $this->responseTypes)));
}

$auth_endpoint .= (strpos($auth_endpoint, '?') === false ? '?' : '&') . http_build_query($auth_params, null, '&');
$auth_endpoint .= (strpos($auth_endpoint, '?') === false ? '?' : '&') . http_build_query($auth_params, null, '&', $this->$enc_type);

$this->commitSession();
$this->redirect($auth_endpoint);
Expand All @@ -636,7 +638,7 @@ public function requestClientCredentialsToken() {
);

// Convert token params to string format
$post_params = http_build_query($post_data, null, '&');
$post_params = http_build_query($post_data, null, '&', $this->$enc_type);

return json_decode($this->fetchURL($token_endpoint, $post_params, $headers));
}
Expand Down Expand Up @@ -671,7 +673,7 @@ public function requestResourceOwnerToken($bClientAuth = FALSE) {
}

// Convert token params to string format
$post_params = http_build_query($post_data, null, '&');
$post_params = http_build_query($post_data, null, '&', $this->$enc_type);

return json_decode($this->fetchURL($token_endpoint, $post_params, $headers));
}
Expand Down Expand Up @@ -707,7 +709,7 @@ private function requestTokens($code) {
}

// Convert token params to string format
$token_params = http_build_query($token_params, null, '&');
$token_params = http_build_query($token_params, null, '&', $this->$enc_type);

return json_decode($this->fetchURL($token_endpoint, $token_params, $headers));

Expand All @@ -733,7 +735,7 @@ public function refreshToken($refresh_token) {
);

// Convert token params to string format
$token_params = http_build_query($token_params, null, '&');
$token_params = http_build_query($token_params, null, '&', $this->$enc_type);

$json = json_decode($this->fetchURL($token_endpoint, $token_params));

Expand Down Expand Up @@ -1560,4 +1562,22 @@ protected function unsetSessionKey($key) {

unset($_SESSION[$key]);
}

public function setUrlEncoding($curEncoding)
{
switch ($curEncoding)
{
case PHP_QUERY_RFC1738:
$this->enc_type = PHP_QUERY_RFC1738;
break;

case PHP_QUERY_RFC3986:
$this->enc_type = PHP_QUERY_RFC3986;
break;

default:
break;
}

}
}

0 comments on commit a8beafb

Please sign in to comment.