Other services can authenticate incoming requests on behalf of the DC/OS Identity and Access Manager (IAM) component, using public key cryptography. This works if the authentication token presented by the client has been signed by the IAM with its private key.
Bouncer JSON Web Key Set (JWKS) endpoint
The Bouncer’s JWKS endpoint (/auth/jwks
) provides the public key details required for verifying the signature of type RS256 JWTs issued by Bouncer. The JSON document data structure emitted by that endpoint is compliant with RFC 7517. Within that data structure, the public key is parameterized according to RFC 7518.
Here is an example response:
Constructing the public key from the JWKS data
The two parameters that fully define an RSA public key are the modulus (n
) and the exponent (e
). Both are integers encoded using Base64 as specified in RFC 7518
Use the tool of your choice to generate the public key representation that you will need to validate the authentication token.
Here is a Python example based on the cryptography module (which uses OpenSSL as its back-end). This example generates a public key object from a given exponent and modulus directly.
Verifying the authentication token using the public key
This example uses the Python PyJWT module, auth token verification, and extraction of the user ID:
The decode method verifies the token signature and expiration time and raises an exception if the token is invalid.
Complete token verification example
This example validates an authentication token. Here is the example token
Here is Python code for performing the validation, following the instructions given above:
The response indicates that this is a valid authentication token for peter
.