Skip to content

Commit

Permalink
Update base url of openid configuration loader (#35)
Browse files Browse the repository at this point in the history
* Update base url

* Update tests
  • Loading branch information
ricklambrechts authored Feb 13, 2024
1 parent 696ebe1 commit abfc107
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/OpenIDConfiguration/OpenIDConfigurationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ protected function getConfigurationFromIssuer(): OpenIDConfiguration
{
$url = $this->getOpenIDConfigurationUrl();

$pendingRequest = Http::baseUrl($url);
if (!$this->tlsVerify) {
$pendingRequest->withoutVerifying();
}
$response = $pendingRequest->get($url);
$response = Http::baseUrl($this->issuer)
->when(!$this->tlsVerify, function ($pendingRequest) {
return $pendingRequest->withoutVerifying();
})
->get($url);

if (!$response->successful()) {
throw new OpenIDConfigurationLoaderException(
Expand Down Expand Up @@ -97,6 +97,6 @@ protected function getConfigurationFromIssuer(): OpenIDConfiguration

protected function getOpenIDConfigurationUrl(): string
{
return $this->issuer . '/.well-known/openid-configuration';
return '/.well-known/openid-configuration';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function testLoaderThrowsExceptionWhenProviderReturns400ResponseCodeAsser

$context = $exception->context();
$this->assertSame("https://provider.rdobeheer.nl", $context['issuer']);
$this->assertSame("https://provider.rdobeheer.nl/.well-known/openid-configuration", $context['url']);
$this->assertSame("/.well-known/openid-configuration", $context['url']);
$this->assertSame(400, $context['response_status_code']);
}
}
Expand All @@ -137,7 +137,7 @@ public function testLoaderThrowsExceptionWhenProviderReturns500ResponseCodeAsser

$context = $exception->context();
$this->assertSame("https://provider.rdobeheer.nl", $context['issuer']);
$this->assertSame("https://provider.rdobeheer.nl/.well-known/openid-configuration", $context['url']);
$this->assertSame("/.well-known/openid-configuration", $context['url']);
$this->assertSame(500, $context['response_status_code']);
}
}
Expand All @@ -156,7 +156,7 @@ public function testLoaderThrowsExceptionWhenProviderReturns200ButNullResponse()

$context = $exception->context();
$this->assertSame("https://provider.rdobeheer.nl", $context['issuer']);
$this->assertSame("https://provider.rdobeheer.nl/.well-known/openid-configuration", $context['url']);
$this->assertSame("/.well-known/openid-configuration", $context['url']);
$this->assertSame(200, $context['response_status_code']);
$this->assertSame('', $context['response_body']);
}
Expand All @@ -176,7 +176,7 @@ public function testLoaderThrowsExceptionWhenProviderReturns200ButStringResponse

$context = $exception->context();
$this->assertSame("https://provider.rdobeheer.nl", $context['issuer']);
$this->assertSame("https://provider.rdobeheer.nl/.well-known/openid-configuration", $context['url']);
$this->assertSame("/.well-known/openid-configuration", $context['url']);
$this->assertSame(200, $context['response_status_code']);
$this->assertSame('some invalid response', $context['response_body']);
}
Expand Down

0 comments on commit abfc107

Please sign in to comment.