How to configure JWT authentication
Configure IBM® z/OS® Connect to perform authentication using the claims in a JSON Web Token (JWT) and create the authenticated user from the values of the JWT claims.
- Map the identity in the JWT claims to an LDAP user ID. For more information, see How to configure JWT authentication mapped to LDAP
- Map the identity in the JWT claims to a SAF user ID. For more information, see How to configure JWT authentication
This task is applicable when using IBM z/OS Connect as an API provider.
Before you begin
- You should be familiar with the information in API provider third-party authentication.
- You must have either an X.509 certificate that contains the public key of the private key that signed the JWT. This key is used to validate the JWT signature. Consult the security administrator of the JWT issuer for how to obtain a suitable X.509 certificate. Or if supported by the JWT issuer, a JWK endpoint URL and the TLS certificates required to establish an HTTPS connection to that URL.
- You need to know the claims that are present in the JWT.
- You must have write access to the configuration file.
About this task
Configure IBM z/OS Connect to perform JWT authentication. This configuration uses the OpenID Connect Client feature of WebSphere Application Server Liberty Profile to accept the JWT as an authentication token.
This task validates the JWT and creates the authenticated user from the values of the JWT claims, it does not map the JWT to a user registry user.
The authenticated user is created from the value of the JWT claim name specified on the
userIdentifier attribute of the openidConnectClient
server
configuration element. The group values associated with the authenticated user subject are obtained
from the claim name specified on the groupIdentifier attribute of the
openIdConnectClient
element.
The group values associated with the authenticated user subject are compared against the roles defined for the API operation being invoked.
- The JWT is sent to IBM z/OS Connect in an HTTP Authorization request header field as a Bearer token.
- The RS256 algorithm is used to sign the JWT.
- The "sub" (Subject) claim in the JWT is the identity to be authenticated.
- The "accessLevels" custom claim contains the roles assigned to the identity for API authorization.
{ "alg": "RS256" }.
{ "iss": "idg",
"sub": "SallyKwan",
"aud": "myEntity",
"exp": 1496230040,
"iat": 1496229740 }.
"accessLevels": "Manager" }.
RSASHA256signature....
- The header contains an
alg
(algorithm) with the valueRS256
, which is the hashing algorithm that was used to sign the JWT.RS256
is RSA Signature with SHA-256. - The
iss
(issuer) claim,idg
identifies the principal that issued the JWT. In this example, the JWT was issued by IBM DataPower®, which usesidg
as its default issuer value. - The
sub
(subject) claim,SallyKwan
is an identity. If the JWT is valid, its signature is verified and other claims such as "aud" and "iss" match the required values then this value will be the authenticated user. - The
aud
(audience) claim,myEntity
identifies the intended recipient of the JWT. Theaud
claim is optional. It can be used to identify a specific IBM z/OS Connect or a target API. - The
exp
(expiration time) claim identifies the expiration time on or after which the JWT must not be accepted for processing. This is expressed as a JSON numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time, ignoring leap seconds. - The
iat
(issued at) claim identifies the time at which the JWT was issued. This is expressed as a JSON numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time, ignoring leap seconds. - The
accessLevels
is a custom claim indicating the access or role assigned to the identity. Your environment may use a registered claim, for example scope, or an alternative custom claim for this purpose. - The
signature
(not shown) is calculated using the header and the payload. The signature certifies that only the party holding the private key is the one that created and signed the JWT, and it also verifies that the claims have not been tampered with.
- If a JWT contains a jti (JWT ID) that is identical to a JWT previously used for
authentication with IBM z/OS Connect, the request is
considered to be a replay attack. A jti is an optional claim. By default, a subsequent
request with the same "jti" claim value will be rejected. To allow multiple requests to use the same
"jti" claim value configure tokenReuse="true" on the
openidConnectClient
configuration element. - If the JWT has been issued by a JWT provider that supports JWK (JSON Web Key) or has been signed using the HMAC-SHA256 algorithm, then some steps in this procedure must be modified. For more information, see Alternative configuration when using JWK or the HS256 algorithm.
- Only JWS type tokens are supported, not tokens of type JWE.
Procedure
Results
A JWT is used to authenticate an API request to IBM z/OS Connect. The identity in the JWT is used for authorization control.
Alternative configuration when using JWK or the HS256 algorithm
openidConnectClient
element.Procedure
- If the public key is retrieved from a JWK endpoint, you specify the JWK endpoint URL on
the
jwkEndpointUrl
attribute. - If the JWT is signed by using a shared secret key with the HMAC-SHA256 algorithm, you
define the shared secret key on the
sharedKey
orclientSecret
attributes.