If you want to use RS256 or ES256 to verify your JWTs, then when creating a JWT credential,
select RS256
or ES256
as the algorithm
, and explicitly upload the public key
in the rsa_public_key
field (including for ES256 signed tokens). For example, rsa_public_key=@/path/to/public_key.pem
.
When creating the signature, make sure that the header is:
{
"typ": "JWT",
"alg": "RS256"
}
Secondly, the claims must contain the secret’s key
field (this isn’t your private key used to generate
the token, but just an identifier for this credential) in the configured claim (from config.key_claim_name
).
That claim is iss
(issuer field) by default. Set its value to our previously created credential’s key
.
The claims may contain other values. The claim is searched in both the JWT payload and header,
in that order.
{
"iss": "a36c3049b36249a3c9f8891cb127243c"
}
Then, create the signature using your private keys. Using the JWT debugger at
jwt.io, set the right header (RS256), the claims (iss
, etc.), and the
associated public key. Then, append the resulting value in the Authorization
header, for example:
curl http://localhost:8000/{routePath} \
-H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxM2Q1ODE0NTcyZTc0YTIyYjFhOWEwMDJmMmQxN2MzNyJ9.uNPTnDZXVShFYUSiii78Q-IAfhnc2ExjarZr_WVhGrHHBLweOBJxGJlAKZQEKE4rVd7D6hCtWSkvAAOu7BU34OnlxtQqB8ArGX58xhpIqHtFUkj882JQ9QD6_v2S2Ad-EmEx5402ge71VWEJ0-jyH2WvfxZ_pD90n5AG5rAbYNAIlm2Ew78q4w4GVSivpletUhcv31-U3GROsa7dl8rYMqx6gyo9oIIDcGoMh3bu8su5kQc5SQBFp1CcA5H8sHGfYs-Et5rCU2A6yKbyXtpHrd1Y9oMrZpEfQdgpLae0AfWRf6JutA9SPhst9-5rn4o3cdUmto_TBGqHsFmVyob8VQ'