Skip to content

Commit

Permalink
feat: set useragent (#370)
Browse files Browse the repository at this point in the history
* Set useragent

* Update CHANGELOG.md

* Set default useragent
  • Loading branch information
ricklambrechts authored May 4, 2023
1 parent e6eab93 commit 8ec206b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Support for signed and encrypted ID Token. #305
* Update construct typehint in docblock. #364
* Fixed LogoutToken verification for single value aud claims #334
* Added function to set useragent #370

### Added
- Support for signed and encrypted UserInfo response. #305
Expand Down
6 changes: 6 additions & 0 deletions src/OpenIDConnectClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,7 @@ protected function fetchURL(string $url, string $post_body = null, array $header
// Allows to keep the POST method even after redirect
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent());

// Default content type is form encoded
$content_type = 'application/x-www-form-urlencoded';
Expand Down Expand Up @@ -2058,4 +2059,9 @@ public function supportsAuthMethod(string $auth_method, array $token_endpoint_au

return in_array($auth_method, $token_endpoint_auth_methods_supported, true);
}

protected function getUserAgent(): string
{
return "jumbojett/OpenID-Connect-PHP";
}
}

0 comments on commit 8ec206b

Please # to comment.