Skip to content

Commit 0d24bda

Browse files
IlanaRadinskycicnavipradtke
authored
Logout tokens should have typ header with value 'logout+jwt' (#185)
* Logout tokens should have typ header with value 'logout+jwt' * Update test to include typ header check * Mark SSP composer-module-installer as allowed plugin * Ignore vendor/bin/psalm in psalm to avoid it evaluating itself Co-authored-by: Marko Ivančić <[email protected]> Co-authored-by: Patrick Radtke <[email protected]>
1 parent 38a7dd8 commit 0d24bda

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@
4949
"preferred-install": {
5050
"*": "dist"
5151
},
52-
"sort-packages": true
52+
"sort-packages": true,
53+
"allow-plugins": {
54+
"simplesamlphp/composer-module-installer": true
55+
}
5356
},
5457
"autoload": {
5558
"psr-4": {

lib/Services/LogoutTokenBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function forRelyingPartyAssociation(RelyingPartyAssociationInterface $rel
2323
{
2424
$logoutTokenBuilder = $this->jsonWebTokenBuilderService
2525
->getDefaultJwtTokenBuilder()
26+
->withHeader('typ', 'logout+jwt')
2627
->permittedFor($relyingPartyAssociation->getClientId())
2728
->relatedTo($relyingPartyAssociation->getUserId())
2829
->withClaim('events', ['http://schemas.openid.net/event/backchannel-logout' => new stdClass()])

psalm.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<!-- Ignore deprecated classes -->
1818
<ignoreFiles>
1919
<directory name="www/assets" />
20+
<file name="vendor/bin/psalm" />
2021
</ignoreFiles>
2122
</projectFiles>
2223

@@ -45,7 +46,7 @@
4546
<!-- Ignore UnresolvableInclude on CLI-scripts -->
4647
<UnresolvableInclude>
4748
<errorLevel type="suppress">
48-
<file name="tests/bootstrap.php" />
49+
<file name="tests/bootstrap.php" />
4950
</errorLevel>
5051
</UnresolvableInclude>
5152
</issueHandlers>

tests/Services/LogoutTokenBuilderTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class LogoutTokenBuilderTest extends TestCase
3232
private static string $userId = 'user123';
3333
private static string $sessionId = 'session123';
3434
private static string $backChannelLogoutUri = 'https//some-host.org/logout';
35+
private static string $logoutTokenType = 'logout+jwt';
3536
/**
3637
* @var mixed
3738
*/
@@ -106,5 +107,8 @@ public function testCanGenerateSignedTokenForRelyingPartyAssociation(): void
106107
)
107108
)
108109
);
110+
111+
$this->assertTrue($parsedToken->headers()->has('typ'));
112+
$this->assertSame($parsedToken->headers()->get('typ'), self::$logoutTokenType);
109113
}
110114
}

0 commit comments

Comments
 (0)