Skip to content

Commit abfc107

Browse files
Update base url of openid configuration loader (#35)
* Update base url * Update tests
1 parent 696ebe1 commit abfc107

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/OpenIDConfiguration/OpenIDConfigurationLoader.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ protected function getConfigurationFromIssuer(): OpenIDConfiguration
3838
{
3939
$url = $this->getOpenIDConfigurationUrl();
4040

41-
$pendingRequest = Http::baseUrl($url);
42-
if (!$this->tlsVerify) {
43-
$pendingRequest->withoutVerifying();
44-
}
45-
$response = $pendingRequest->get($url);
41+
$response = Http::baseUrl($this->issuer)
42+
->when(!$this->tlsVerify, function ($pendingRequest) {
43+
return $pendingRequest->withoutVerifying();
44+
})
45+
->get($url);
4646

4747
if (!$response->successful()) {
4848
throw new OpenIDConfigurationLoaderException(
@@ -97,6 +97,6 @@ protected function getConfigurationFromIssuer(): OpenIDConfiguration
9797

9898
protected function getOpenIDConfigurationUrl(): string
9999
{
100-
return $this->issuer . '/.well-known/openid-configuration';
100+
return '/.well-known/openid-configuration';
101101
}
102102
}

tests/Feature/OpenIDConfiguration/OpenIDConfigurationLoaderTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testLoaderThrowsExceptionWhenProviderReturns400ResponseCodeAsser
118118

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

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

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

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

0 commit comments

Comments
 (0)