Signed Tokens (JWS)
The JWS object, signature algorithms and token serializers are part of the signature component (web-token/jwt-signature). Claim and header checkers are decoupled and can be found in the checker component (web-token/jwt-checker).
Why are signature and checker components not together? The main reason is that when you issue signed tokens, you do not need any checker. Those components are decoupled to avoid the installation of unnecessary files.
The signature and loading processes have been completely reviewed.
In the examples below, we suppose we already have a JWK object ($key).
Signed Tokens Creation
Before
<?php
use Jose\Factory\JWKFactory;
use Jose\Factory\JWSFactory;
$header = [
'alg' => 'RS256',
];
$jws = JWSFactory::createJWSToCompactJSON(
$claims, // The payload
$key, // The private/shared key used to sign
$header // The token protected header
);After
Signed Tokens Loading
Before
After
Please note that it is important to check the token header before the verification of the signature. It will help you to reject tokens signed with unsupported algorithms.
Last updated
Was this helpful?