CMiC API and OAuth 2.0 Integration - OAuth 2.0 - Troubleshooting
Overview
This
Troubleshooting
Debugging
Enable the OAuth flow debugging by requesting DBAs to enable the dynamic logging:
<logger name='cmic.oauth2.filter' level='FINE'/>
Requirements
-
Server logs are required since the root error will be present, including the authorization bearer value used during processing.
-
If available, the error reference is a part of the error message sent back to the client.
-
Please provide the error response, which can include the error message/error reference that is a link to the error in logs, and the time which the error occurred.
Error Responses
500 - Failed to process request properly.
The reason could be one of the following:
-
Application is not registered
-
Failed to load JSON web key set
-
Another unexpected processing error
401 - Unauthorized Access
The reason could be one of the following:
-
No Authorization Bearer value
-
Missing Authorization header
-
Missing required claim
-
Client validation failed (ip check)
-
Token expired
-
Unable to validate signature
Check to Perform
Depending on the error, one or more of the following checks could be required:
-
Did the request have the Authorization header with the Bearer <token> value?
-
The application is registered in the CMiC API Security.
-
Application ID and issuer values must be present in the token.
-
-
The token has the right set of claims.
-
You may need to match the key claims with the application registered.
-
Check the Token Validation section for more details.
-
-
If the IP check failed,
-
Was the ipaddr claim present?
-
Was the ipaddr claim value not found in the request IP (x-forwarded-for)?
-
The problem can be introduced because of the VPN, where the token has the real client IP, but the request has the VPN IP, and those would not match. The client's IT should verify why there’s a difference.
-
It is not suggested to disable IP check, especially in production. There is ability to disable it by setting the cmic.oauth2.ipcheck.enabled property to "false" in cmicapp.properties.
-
Token Validation
The following are two sites where you can take a JWT token and it will convert to a readable set of claims present.
-
https://jwt.io/
-
https://jwt.ms/
The token to use is what is in the server logs noted with the error (it will start with "ey").
Azure Token
Version 1
Token must have claims:
-
appid
-
iss
-
ipaddr (not present for client credentials flow)
-
One of the following: cmicuser, email, or upn
Version 2
Token must have claims:
-
aud
-
iss
-
ipaddr (not present for client credentials flow)
-
One of the following: cmicuser, email, or upn
Verify Server is Configured Properly for OAuth
Test an API call from the browser (e.g. https://<your server>/<env>/cmic-field-rest-api/jersey/v1/login) and see if any of the following occurs:
-
Does it prompt for username and password?
If yes, then the setup is incorrect. This means it's protected by Basic Authentication and DBAs need to review the setup.
-
Does it redirect to a sign-in page?
If yes, then setup is incorrect. This means it's protected by Access Manager and DBAs need to review the setup.
-
If you're still unsure, verify that the API request is hitting the API server by checking the access.log. If it is not, there could be a network routing issue that your IT should review.