Home
About
Search
Welcome to M-Files Empower – our new support experience. We'd love to hear what you think!Give feedback
Home/Support and troubleshooting/Troubleshooting/Error resolution

"The JWT token did not pass validation." Error with the OAuth Authentication

Last updated on 30 September 2024

Admin
AD FS Authentication

Overview

At this scenario, you have configured Federated authentication Protocol as "OpenID Connect or OAuth 2.0" and "AccessTokenType" = JWT under server specific settings.  When you are using OAuth for authenticating users, the user may end up getting randomly a "The JWT token did not pass validation." error when trying to login to a vault.  At this point of time, the M-Files server is validating the token provided by identity provider.  The validation can be failed for different reasons.

Root Cause #1:

The reason for this error may be that the identity provider (IdP) for OAuth is rotating signing keys for the JWT tokens for the authentication procedure periodically.

Solution

By default, M-Files check the change of the keys every 24 hours. If the IdP is rotating the keys more often you must set MetadataCheckIntervalInMinutes setting to lower value in the federated authentication configuration:

1. Open M-Files Admin.

2. In the left-side tree view, expand the desired connection to M-Files Server.

3. In the left-side tree view, expand the document vault of your choice.

4. Still in the left-side tree view, select Configurations.

5. In the gray navigation area, select Federated Authentication and then open the Configuration tab.

6. Expand relevant Scope and its Configuration.

7. Expand Settings and Server section and if not set, set Show Advanced Options to "Yes".

8. Set "MetadataCheckIntervalInMinutes": <check time in minutes>

9. Click Save.

The "MetadataCheckIntervalInMinutes" setting must be set lower than the IdP's JWT token keys rotating time.

Root Cause #2

OAuth

Validating the authentication data failed:

System.ApplicationException: The JWT token did not pass validation. ---> Microsoft.IdentityModel.Tokens.SecurityTokenInvalidSignatureException: IDX10504: Unable to validate signature, token does not have a signature: 'System.String'.

   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateSignature(String token, TokenValidationParameters validationParameters)

   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)

   at MFiles.AuthenticationProviders.OAuth.ServerAuthentication.Validate(IStringDictionary authdata, IStringDictionary configuration)

   --- End of inner exception stack trace ---

   at MFiles.AuthenticationProviders.OAuth.ServerAuthentication.Validate(IStringDictionary authdata, IStringDictionary configuration)

Note the error message: Unable to validate signature, token does not have a signature: 'System.String'.

For this error, make sure you are using the right token for validation.  In general, in the OpenID authentication flow, there are 2 tokens provided.  Access-Token and ID-Token.  Use the token depending upon the version of the endpoint version you are using in the configuration.

Identity provider Entra ID :

If you are using Entra ID previously known as Azure Ad, the following root cause and solution would be applicable. 

Look at the metadata endpoint configured.  Particularly highlighted version information.

https://login.microsoftonline.com/49147cec-ae74-4ac3-840e-b8310efd0270/V2.0/.well-known/openid-configuration

If the version is V2.0/.well-known you must use ID-Token.  For that, UseIdTokenAsAccessToken = true, under client specific settings. 

You must also set "Keep UseIdTokenAsAccessToken value" = true, under server specific settings.

If you don’t find "Keep UseIdTokenAsAccessToken value" in the configuration menu, go to advanced tab and write directly in JSON format under server specific settings.

"PreserveClientSpecificSetting_UseIdTokenAsAccessToken" : "true"

When the medataendpoint has no version information, it means that you are using V1.0.

https://login.microsoftonline.com/49147cec-ae74-4ac3-840e-b8310efd0270/.well-known/openid-configuration

Make sure UseIdTokenAsAccessToken = false.  This will let M-Files Server use Access-Token and M-Files server can successfully parse as JWT token.

Refer Section 5.6 on Preserving Manually Defined Settings in the following document.

Configuring OpenID Connect and OAuth 2.0 for M-Files Authentication.pdf

Other identity providers :

Try with alternate values for UseIdTokenAsAccessToken. 

By attempting alternate values, you are trying to use ID-Token or Access-Token and depending upon the identity provider either one should be successful.  Ideally, when you have enabled to use OpenID protocol at the identity provider, using ID-Token  ( UseIdTokenAsAccessToken = true ) should help to successful JWT token verification.

You can use desktop client to test the federated authentication.  Desktop client does not use any cached configuration so you can always make sure that you are using the updated configuration.

Root Cause #3:

OAuth

Validating the authentication data failed:

System.ApplicationException: The JWT token did not pass validation. ---> Microsoft.IdentityModel.Tokens.SecurityTokenInvalidAudienceException: IDX10214: Audience validation failed. Audiences: 'System.String'. Did not match: validationParameters.ValidAudience: 'System.String' or validationParameters.ValidAudiences: 'System.String'.

   at Microsoft.IdentityModel.Tokens.Validators.ValidateAudience(IEnumerable`1 audiences, SecurityToken securityToken, TokenValidationParameters validationParameters)

   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateTokenPayload(JwtSecurityToken jwtToken, TokenValidationParameters validationParameters)

   at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken)

   at MFiles.AuthenticationProviders.OAuth.ServerAuthentication.Validate(IStringDictionary authdata, IStringDictionary configuration)

   --- End of inner exception stack trace ---

   at MFiles.AuthenticationProviders.OAuth.ServerAuthentication.Validate(IStringDictionary authdata, IStringDictionary configuration)

Note the error message: Audience validation failed.

For this error, make sure that you have configured the right Audience value, under server specific settings. Every token provided by identity provider is prepared for a specific audience.  When JWT token is validated MFServer has to use correct Audience value for a successful validation.

If you are using Entra ID previously known as Azure Ad, please check your metadata endpoint version and configure Audience value accordingly.

For a token provided by a V2.0 endpoint, Audience value must be same as ClientID.  Make sure ClientID and Audience is same.

Token provided by V1.0 endpoint, Audience value must match with resource parameter.

For other identify providers, Audience value must be same as ClientID.  Make sure ClientID and Audience is same.

Still need help?