Testing OIDC Encrypted ID Token with IS
This page describes how you can configure and test OIDC Encrypted ID Token with Identity Server 5.5.0
Setup Playground Sample
First, you should setup the Playground sample app.
Configuring the service provider
The next step is to configure the service provider.
Configuring Service Provider Public Certificate
The following steps describe how to configure a service provider public certificate:
Create a new keystore.
keytool -genkey -alias wso2carbon -keyalg RSA -keysize 2048 -keystore testkeystore.jks -dname "CN=*.test.com,OU=test,O=test,L=MPL,ST=MPL,C=FR" -storepass wso2carbon -keypass wso2carbon -validity 10950
Export public key of the new keystore to a file with the name of client-id of oauth application.
keytool -export -alias wso2carbon -file <client-id> -keystore testkeystore.jks
Get the cert in X509 format.
keytool -printcert -rfc -file <client-id>
You will see the public certificate in X509 format in the console. Copy the content of the certificate. (Sample output given below)
-----BEGIN CERTIFICATE----- MIIDVzCCAj+gAwIBAgIETCZA8zANBgkqhkiG9w0BAQsFADBcMQswCQYDVQQGEwJG UjEMMAoGA1UECBMDTVBMMQwwCgYDVQQHEwNNUEwxDTALBgNVBAoTBHRlc3QxDTAL BgNVBAsTBHRlc3QxEzARBgNVBAMMCioudGVzdC5jb20wHhcNMTgwMjE0MDYzNjE3 WhcNNDgwMjA3MDYzNjE3WjBcMQswCQYDVQQGEwJGUjEMMAoGA1UECBMDTVBMMQww CgYDVQQHEwNNUEwxDTALBgNVBAoTBHRlc3QxDTALBgNVBAsTBHRlc3QxEzARBgNV BAMMCioudGVzdC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCz Gc/BcXCiIagLhXs1g90H+PbfZyXLzwFJ+YmsKMikcffhyopDD+fnFjHb1+XXSnUh 4XzQlFba6m2vIOK8uquMhZKMv/E7Vxkl/ADTuw/BgpZRut4p88Fn8OWZlrJfoi3o hvgfxSMratvxLMp1Qe0BzjwoBDB9r+h9pj8kCpHC824eUGIR0FZsW9lnoJP2LegL nAcOJuNBoeWC0wwNu0sgIJwjsKp3G3glm8B4GdZvbF8aW1QRAk36sh8+0GXrRnAz aGcRAqt7CjeZmt5Dsuy0lfp5i1xf5myPOH7MwKHqQQ56Wu9O479NdDVLkJ0xne2r ZTCwMeGhQQH5hI+SYlxjAgMBAAGjITAfMB0GA1UdDgQWBBTzS+bja//25xb+4wcP gMN6cJZwoDANBgkqhkiG9w0BAQsFAAOCAQEAdhZ8romzQQKF9c8tJdIhUS4i7iJh oSjBzN+Ex9+OJcW6ubcLb8pai/J3hcvMadAybR1A17FkETLFmG9HkuEN9o2jfU7c 9Yz5d0pqO8qNKXSqHky5c+zA4vzLZGsgKyDZ5a0p9Qpsat3wnA3UGZPRoVGV5153 Mb0J1n1uubxGobEEzR2BXaKO9YEWAMQwGRdQCGBaIeGUOpqSUJMLYirDXL03je3g mYzWclLTEHpIYy+a66tmF9uTGgyys33LPm2pQ+kWd8FikWolKKBqp+IPU5QdUQi1 DdFHsyNqrnms6EOQAY57Vnf91RyS7lnO1T/lVR6SDk9+/KDBEL1b1cy7Dg== -----END CERTIFICATE-----
Navigate to service provider.
Edit and paste the certificate content copied in the above step and Click Update.
Enable ID Token Encryption
Follow the below steps to enable ID Token Encryption:
Navigate to Service Provider > Inbound Authentication Configuration > OAuth/OpenID Connect Configuration and Click Edit.
Click Enable ID Token Encryption to enable id_token encryption.
Once you enable id_token encryption, two select boxes will be visible to choose your preferred encryption algorithm and encryption method.
Encryption Algorithm: Asymmetric encryption algorithm that is used to encrypt the Content Encryption Key (CEK), using the public key of the service provider.
Encryption Method: Symmetric encryption algorithm that is used to encrypt the JWT claims set using the CEK.
Testing the flow - Authorization Code Grant Type
Visit the URL http://wso2is.local:8080/playground2/oauth2.jsp to start the application.
Enter the following details and click Authorize.
- Authorization Grant Type: Authorization Code
- Client ID: (the client id received at the application registration step in Identity Server)
- Scope:openid (This scope is a requirement to provide user information. Any token without this scope will not be allowed to access user information.)
- Callback URL: http://wso2is.local:8080/playground2/oauth2client
- Authorize Endpoint: https://localhost:9443/oauth2/authorize
Sign in with the user credentials.
Click Approve to consent to this action.
- Provide the following details and click Get Access Token.
- Callback URL: http://wso2is.local:8080/playground2/oauth2client
- Access Token Endpoint: https://localhost:9443/oauth2/token
- Client Secret: (client secret received at the application registration)
- At this point, the application receives the Access Token and Encrypted ID Token.
In order to decrypt the ID Token, you need to provide the private key of the client.
Paste the copied private key in Client Private Key text area.
Click Decrypt and the decrypted ID Token details will be displayed.
Testing the flow - Implicit Grant Type
Before you begin, you must first set up the sample webapp.
Visit the URL http://wso2is.local:8080/playground2/oauth2.jsp to start the application.
Enter the following details and click Authorize.
- Authorization Grant Type: Implicit
- Client ID: (the client id received at the application registration step in Identity Server)
- Scope:openid (This scope is a requirement to provide user information. Any token without this scope will not be allowed to access user information.)
- Callback URL: http://wso2is.local:8080/playground2/oauth2client
- Authorize Endpoint: https://localhost:9443/oauth2/authorize
Sign in with the user credentials.
- Click Approve to consent to this action.
- At this point, the application receives the Access Token and the encrypted ID Token.
In order to decrypt the ID Token, you need to provide the private key of the client.
Paste the copied private key in Client Private Key text area.
Click Decrypt and the decrypted ID Token details will be displayed.
Testing the flow - Password Grant Type
Before you begin, you must first set up the sample webapp.
Visit the URL http://wso2is.local:8080/playground2/oauth2.jsp to start the application.
Enter the following details and click Authorize.
- Authorization Grant Type: Resource Owner
- Client ID: (the client id received at the application registration step in Identity Server)
- Client Secret: (the client secret received at the application registration)
- Resource Owner User Name: (username)
- Resource Owner Password: (password of user)
- Scope:openid (This scope is a requirement to provide user information. Any token without this scope will not be allowed to access user information.)
Access Token Endpoint: https://localhost:9443/oauth2/ token
- At this point, the application receives the Access Token and the encrypted ID Token.
In order to decrypt the ID Token, you need to provide the private key of the client.
Paste the copied private key in Client Private Key text area.
Click Decrypt and the decrypted ID Token details will be displayed.