Skip to content

Commit 03c7ad1

Browse files
committed
Introduce JWK suite
1 parent 37c62c7 commit 03c7ad1

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/Codebooks/JwtTypesEnum.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ enum JwtTypesEnum: string
88
{
99
case EntityStatementJwt = 'entity-statement+jwt';
1010
case JwkSetJwt = 'jwk-set+jwt';
11+
case Jwt = 'JWT';
1112
case TrustMarkJwt = 'trust-mark+jwt';
1213
case TrustMarkDelegationJwt = 'trust-mark-delegation+jwt';
1314
}

src/Federation/Factories/EntityStatementFactory.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace SimpleSAML\OpenID\Federation\Factories;
66

77
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
8+
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
9+
use SimpleSAML\OpenID\Codebooks\JwtTypesEnum;
810
use SimpleSAML\OpenID\Federation\EntityStatement;
911
use SimpleSAML\OpenID\Jwk\JwkDecorator;
1012
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory;
@@ -39,6 +41,11 @@ public function fromData(
3941
array $payload,
4042
array $header,
4143
): EntityStatement {
44+
45+
if (!array_key_exists(ClaimsEnum::Typ->value, $header)) {
46+
$header[ClaimsEnum::Typ->value] = JwtTypesEnum::EntityStatementJwt->value;
47+
}
48+
4249
return new EntityStatement(
4350
$this->jwsDecoratorBuilder->fromData(
4451
$signingKey,

src/Jwk.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\OpenID;
6+
7+
use Psr\Log\LoggerInterface;
8+
use SimpleSAML\OpenID\Jwk\Factories\JwkDecoratorFactory;
9+
10+
class Jwk
11+
{
12+
protected ?JwkDecoratorFactory $jwkDecoratorFactory = null;
13+
14+
public function __construct(
15+
protected readonly ?LoggerInterface $logger = null,
16+
) {
17+
}
18+
19+
public function jwkDecoratorFactory(): JwkDecoratorFactory
20+
{
21+
return $this->jwkDecoratorFactory ??= new JwkDecoratorFactory();
22+
}
23+
}

0 commit comments

Comments
 (0)