Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/OpenIDConfiguration/OpenIDConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function __construct(
public array $idTokenSigningAlgValuesSupported = [],
public string $userinfoEndpoint = '',
public array $codeChallengeMethodsSupported = [],
public string $endSessionEndpoint = '',
) {
}
}
3 changes: 2 additions & 1 deletion src/OpenIDConfiguration/OpenIDConfigurationLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ protected function getConfigurationFromIssuer(): OpenIDConfiguration
subjectTypesSupported: $response->json('subject_types_supported', []),
idTokenSigningAlgValuesSupported: $response->json('id_token_signing_alg_values_supported', []),
userinfoEndpoint: $response->json('userinfo_endpoint', ''),
codeChallengeMethodsSupported: $response->json('code_challenge_methods_supported', [])
codeChallengeMethodsSupported: $response->json('code_challenge_methods_supported', []),
endSessionEndpoint: $response->json('end_session_endpoint', ''),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ protected function exampleOpenIDConfiguration(
idTokenSigningAlgValuesSupported: ["RS256"],
userinfoEndpoint: "https://provider.example.com/userinfo",
codeChallengeMethodsSupported: $codeChallengeMethodsSupported,
endSessionEndpoint: "https://provider.example.com/endSession",
);
}

Expand Down
1 change: 1 addition & 0 deletions tests/Feature/Http/Controllers/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ protected function exampleOpenIDConfiguration(): OpenIDConfiguration
idTokenSigningAlgValuesSupported: ["RS256"],
userinfoEndpoint: "https://provider.example.com/userinfo",
codeChallengeMethodsSupported: ["S256"],
endSessionEndpoint: "https://provider.example.com/endSession",
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function testConfigurationIsLoaded(): void
$this->assertSame("https://provider.example.com/jwks", $configuration->jwksUri);
$this->assertSame("https://provider.example.com/token", $configuration->tokenEndpoint);
$this->assertSame("https://provider.example.com/userinfo", $configuration->userinfoEndpoint);
$this->assertSame("https://provider.example.com/logout", $configuration->endSessionEndpoint);
}

public function testConfigurationIsLoadedMultipleTimesWhenNotCached(): void
Expand All @@ -60,6 +61,7 @@ public function testConfigurationIsLoadedMultipleTimesWhenNotCached(): void
$this->assertSame("https://provider.example.com/jwks", $configuration->jwksUri);
$this->assertSame("https://provider.example.com/token", $configuration->tokenEndpoint);
$this->assertSame("https://provider.example.com/userinfo", $configuration->userinfoEndpoint);
$this->assertSame("https://provider.example.com/logout", $configuration->endSessionEndpoint);
}

public function testConfigurationIsCached(): void
Expand Down Expand Up @@ -87,6 +89,7 @@ public function testConfigurationIsCached(): void
$this->assertSame("https://provider.example.com/jwks", $configuration->jwksUri);
$this->assertSame("https://provider.example.com/token", $configuration->tokenEndpoint);
$this->assertSame("https://provider.example.com/userinfo", $configuration->userinfoEndpoint);
$this->assertSame("https://provider.example.com/logout", $configuration->endSessionEndpoint);
}

public function testLoaderThrowsExceptionWhenProviderReturns400ResponseCode(): void
Expand Down Expand Up @@ -198,6 +201,7 @@ public function testLoaderReturnsEmptyConfigurationOnEmptyJsonResponse(): void
$this->assertEmpty($configuration->authorizationEndpoint);
$this->assertEmpty($configuration->jwksUri);
$this->assertEmpty($configuration->tokenEndpoint);
$this->assertEmpty($configuration->userinfoEndpoint);
}

public function testConfigurationIsLoadedMultipleTimesWhenCacheStoreIsNull(): void
Expand All @@ -221,6 +225,7 @@ public function testConfigurationIsLoadedMultipleTimesWhenCacheStoreIsNull(): vo
$this->assertSame("https://provider.example.com/jwks", $configuration->jwksUri);
$this->assertSame("https://provider.example.com/token", $configuration->tokenEndpoint);
$this->assertSame("https://provider.example.com/userinfo", $configuration->userinfoEndpoint);
$this->assertSame("https://provider.example.com/logout", $configuration->endSessionEndpoint);
}

protected function fakeSuccessfulResponse(): void
Expand Down Expand Up @@ -264,7 +269,8 @@ protected function fakeSuccessfulResponse(): void
],
"code_challenge_methods_supported" => [
"S256"
]
],
"end_session_endpoint" => "https://provider.example.com/logout"
])
]);
}
Expand Down
40 changes: 40 additions & 0 deletions tests/Feature/OpenIDConnectClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace MinVWS\OpenIDConnectLaravel\Tests\Feature;

use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;
use MinVWS\OpenIDConnectLaravel\OpenIDConnectClient;
use MinVWS\OpenIDConnectLaravel\Tests\TestCase;
use Symfony\Component\HttpFoundation\Response;

class OpenIDConnectClientTest extends TestCase
{
public function testSignOut(): void
{
Http::fake([
'https://provider.example.com/.well-known/openid-configuration' => Http::response([
"end_session_endpoint" => "https://provider.example.com/logout",
])
]);
Config::set('oidc.issuer', 'https://provider.example.com');
Config::set('oidc.configuration_cache.store', null);

$client = app(OpenIDConnectClient::class);

try {
$client->signOut('idToken', 'redirect');
} catch (HttpResponseException $e) {
$this->assertEquals(Response::HTTP_FOUND, $e->getResponse()->getStatusCode());
$this->assertEquals(
'https://provider.example.com/logout?id_token_hint=idToken&post_logout_redirect_uri=redirect',
$e->getResponse()->getTargetUrl()
);

return;
}
}
}