Skip to content

Commit d2731fa

Browse files
committed
Update type header handling when building specific JWS
1 parent 03c7ad1 commit d2731fa

6 files changed

Lines changed: 15 additions & 10 deletions

File tree

src/Federation/Factories/EntityStatementFactory.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ public function fromData(
4141
array $payload,
4242
array $header,
4343
): EntityStatement {
44-
45-
if (!array_key_exists(ClaimsEnum::Typ->value, $header)) {
46-
$header[ClaimsEnum::Typ->value] = JwtTypesEnum::EntityStatementJwt->value;
47-
}
44+
$header[ClaimsEnum::Typ->value] = JwtTypesEnum::EntityStatementJwt->value;
4845

4946
return new EntityStatement(
5047
$this->jwsDecoratorBuilder->fromData(

src/Federation/Factories/TrustMarkDelegationFactory.php

Lines changed: 4 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\TrustMarkDelegation;
911
use SimpleSAML\OpenID\Jwk\JwkDecorator;
1012
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory;
@@ -35,6 +37,8 @@ public function fromData(
3537
array $payload,
3638
array $header,
3739
): TrustMarkDelegation {
40+
$header[ClaimsEnum::Typ->value] = JwtTypesEnum::TrustMarkDelegationJwt->value;
41+
3842
return new TrustMarkDelegation(
3943
$this->jwsDecoratorBuilder->fromData(
4044
$signingKey,

src/Federation/Factories/TrustMarkFactory.php

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

77
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
8+
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
89
use SimpleSAML\OpenID\Codebooks\JwtTypesEnum;
910
use SimpleSAML\OpenID\Federation\TrustMark;
1011
use SimpleSAML\OpenID\Jwk\JwkDecorator;
@@ -40,6 +41,8 @@ public function fromData(
4041
array $header,
4142
JwtTypesEnum $expectedJwtType = JwtTypesEnum::TrustMarkJwt,
4243
): TrustMark {
44+
$header[ClaimsEnum::Typ->value] = $expectedJwtType;
45+
4346
return new TrustMark(
4447
$this->jwsDecoratorBuilder->fromData(
4548
$signingKey,

src/Jwk.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@
44

55
namespace SimpleSAML\OpenID;
66

7-
use Psr\Log\LoggerInterface;
87
use SimpleSAML\OpenID\Jwk\Factories\JwkDecoratorFactory;
98

109
class Jwk
1110
{
1211
protected ?JwkDecoratorFactory $jwkDecoratorFactory = null;
1312

14-
public function __construct(
15-
protected readonly ?LoggerInterface $logger = null,
16-
) {
17-
}
18-
1913
public function jwkDecoratorFactory(): JwkDecoratorFactory
2014
{
2115
return $this->jwkDecoratorFactory ??= new JwkDecoratorFactory();

src/Jwks/Factories/SignedJwksFactory.php

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

77
use SimpleSAML\OpenID\Algorithms\SignatureAlgorithmEnum;
8+
use SimpleSAML\OpenID\Codebooks\ClaimsEnum;
9+
use SimpleSAML\OpenID\Codebooks\JwtTypesEnum;
810
use SimpleSAML\OpenID\Jwk\JwkDecorator;
911
use SimpleSAML\OpenID\Jwks\SignedJwks;
1012
use SimpleSAML\OpenID\Jws\Factories\ParsedJwsFactory;
@@ -38,6 +40,8 @@ public function fromData(
3840
array $payload,
3941
array $header,
4042
): SignedJwks {
43+
$header[ClaimsEnum::Typ->value] = JwtTypesEnum::JwkSetJwt->value;
44+
4145
return new SignedJwks(
4246
$this->jwsDecoratorBuilder->fromData(
4347
$signingKey,

src/VerifiableCredentials/Factories/JwtVcJsonFactory.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public function fromData(
3535
array $payload,
3636
array $header,
3737
): JwtVcJson {
38+
// TODO mivanci Set type header
39+
// $header[ClaimsEnum::Typ->value] = JwtTypesEnum::->value;
40+
3841
return new JwtVcJson(
3942
$this->jwsDecoratorBuilder->fromData(
4043
$signingKey,

0 commit comments

Comments
 (0)