Skip to content

Commit

Permalink
LIMS-960: Add logging to SynchWeb's OIDC auth (#662)
Browse files Browse the repository at this point in the history
* Add extra logging for OIDC endpoint discovery failure

* Log HTTP code, error code

* synctax error

---------

Co-authored-by: John Holt <[email protected]>
  • Loading branch information
gfrn and John Holt authored Sep 28, 2023
1 parent be3e0cc commit ea1011b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion api/src/Authentication/Type/OIDC.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@ function __construct() {
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$errno = curl_errno($ch);

if ($errno || $http_code != 200) {
error_log("Failed to connect to OIDC discovery endpoint. HTTP code: " . $http_code . ". CURL err. no.: " . $errno);
return;
}

curl_close($ch);
$newProviderConfig = json_decode($response);

if(!$newProviderConfig
|| !isset($newProviderConfig->userinfo_endpoint)
|| !isset($newProviderConfig->authorization_endpoint)
|| !isset($newProviderConfig->token_endpoint)) {
error_log("OIDC Authentication provider replied with invalid JSON body");
error_log("OIDC Authentication provider replied with invalid JSON discovery body");
return;
}
$newProviderConfig->b64ClientCreds = base64_encode(
Expand Down

0 comments on commit ea1011b

Please sign in to comment.