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9xRIoWIwnv_rqHGcPpg6hJMfUJMtlLjJaBo0h0veCCZj-fUORidN7EPHNSw9IJF29-nGhw6rmkcD7F8q6WpK8dUfiYGk_QxOCRTw9gpkKKA
When I paste this token into jwt.io
, it automatically fills in a public key and says the signature on the token has been verified. How does it know the public key?
Your JWT public key is available in the Settings tab of your Userfront dashboard. Your JWT public key is truly public. It can be shared anywhere without reducing security. Learn how to verify an access token here.
To verify JWT claimsVerify that the token is not expired. The aud claim in an ID token and the client_id claim in an access token should match the app client ID that was created in the Amazon Cognito user pool. The issuer ( iss ) claim should match your user pool.
From JWT Best Current Practices (RFC 8725) :
The means of determining the keys owned by an issuer is application- specific. As one example, OpenID Connect issuer values are
https
URLs that reference a JSON metadata document that contains ajwks_uri
value that is anhttps
URL from which the issuer's keys are retrieved as a JWK Set (RFC 7517). This same mechanism is used byietf-oauth-discovery
. Other applications may use different means of binding keys to issuers.
The OpenID Connect (OIDC) provider metadata location is documented in OIDC Discovery specification
OpenID Providers supporting Discovery MUST make a JSON document available at the path formed by concatenating the string
/.well-known/openid-configuration
to theIssuer
. The syntax and semantics of.well-known
are defined in RFC 5785 and apply to theIssuer
value when it contains no path component.
The payload of your token is
{
"aud": "https://management.azure.com/",
"iss": "https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/",
"iat": 1563406664,
"nbf": 1563406664,
"exp": 1563410564,
"aio": "42FgYBBtfzSr7br/p4tqeqdl/2wNBgA=",
"appid": "f1f6d55e-cf2c-422d-b186-848624db95e8",
"appidacr": "2",
"idp": "https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/",
"oid": "df9dff8d-bcb5-4b17-8cec-4be1a01f9212",
"sub": "df9dff8d-bcb5-4b17-8cec-4be1a01f9212",
"tid": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"uti": "hi01-8YRuEmLLcxM9L3zAA",
"ver": "1.0"
}
The Issuer
is represented by the iss
claim. If you take the value of iss
, append /.well-known/openid-configuration
to it and pop the resulting URL into your browser, you'll see the OIDC Provider metadata. One of the keys in this metadata document is jwks_uri
which points to another document with a JSON Web Key Set. The latter is a set of JSON Web Keys (JWKs). A JWK is a JSON representation of a crypto key. To identify the desired JWK in the set, the claims x5t
(SHA-1 thumbprint of a X.509 certificate) and/or kid
(key id / alias / name) from the token in question are used.
jwt.io
successfully cheats on the very first step of this whole sequence by pulling OIDC metadata based on iss
claim. If the JWT was issued by a service that did not speak OpenID Connect and/or did not implement all of these related specifications, jwt.io
wouldn't have found the key to validate the signature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With