File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,4 +46,19 @@ public function jsonSerialize(): array
4646 $ this ->name => $ this ->value ,
4747 ];
4848 }
49+
50+
51+ /**
52+ * Check whether the JWKS contains a key with the given key ID.
53+ */
54+ public function hasKeyId (string $ keyId ): bool
55+ {
56+ foreach ($ this ->value [ClaimsEnum::Keys->value ] as $ key ) {
57+ if ($ key [ClaimsEnum::Kid->value ] === $ keyId ) {
58+ return true ;
59+ }
60+ }
61+
62+ return false ;
63+ }
4964}
Original file line number Diff line number Diff line change @@ -65,4 +65,13 @@ public function testCanGetProperties(): void
6565 $ this ->sut ()->jsonSerialize (),
6666 );
6767 }
68+
69+
70+ public function testCanCheckIfKeyIdExists (): void
71+ {
72+ $ sut = $ this ->sut ();
73+
74+ $ this ->assertTrue ($ sut ->hasKeyId ('F4VFObNusj3PHmrHxpqh4GNiuFHlfh-2s6xMJ95fLYA ' ));
75+ $ this ->assertFalse ($ sut ->hasKeyId ('invalid-key-id ' ));
76+ }
6877}
You can’t perform that action at this time.
0 commit comments