Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After upgrading to 8 (OpenIdDict 5) currentuser is null #19893

Closed
1 task done
espindl opened this issue May 21, 2024 · 2 comments
Closed
1 task done

After upgrading to 8 (OpenIdDict 5) currentuser is null #19893

espindl opened this issue May 21, 2024 · 2 comments

Comments

@espindl
Copy link

espindl commented May 21, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Description

I saw the similar issues and tried all of them but my problem still continues. I am seeing 2 lines of log like this:

[17:07:24 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ValidateTokenContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+Protection+ValidateIdentityModelToken.
[17:07:24 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ValidateTokenContext was marked as rejected by OpenIddict.Validation.OpenIddictValidationHandlers+Protection+ValidateIdentityModelToken.
[17:07:24 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was successfully processed by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateAccessToken.
[17:07:24 DBG] The event OpenIddict.Validation.OpenIddictValidationEvents+ProcessAuthenticationContext was marked as rejected by OpenIddict.Validation.OpenIddictValidationHandlers+ValidateAccessToken.
[17:07:24 INF] OpenIddict.Validation.AspNetCore was not authenticated. Failure message: An error occurred while authenticating the current request.
[17:07:24 INF] OpenIddict.Validation.AspNetCore was not authenticated. Failure message: An error occurred while authenticating the current request.

Nothing has changed other than the upgrades.
Only change is upgrading to version 8 (with openiddict 4>5) Applied openiddict migration.

account/login call returns a response (not an error) but the response is empty/default.
If account/login is called with wrong inputs it returns an error. This shows that login is working but returning result is empty.

(Front end is Angular)
Note: When I call the account/login from command line it is successful.

Reproduction Steps

No response

Expected behavior

No response

Actual behavior

No response

Regression?

No response

Known Workarounds

No response

Version

Version 8.1.3

User Interface

Angular

Database Provider

EF Core (Default)

Tiered or separate authentication server

None (Default)

Operation System

Windows (Default)

Other information

No response

@espindl espindl added the bug label May 21, 2024
@maliming
Copy link
Member

hi

You can set your log level to Trace to see more logs.

@maliming maliming removed the bug label May 22, 2024
@espindl
Copy link
Author

espindl commented May 22, 2024

Thank you @maliming . I changed my Serilog level to Verbose and I saw this error.


Microsoft.IdentityModel.Tokens.SecurityTokenMalformedException: IDX14100: JWT is not well formed, there are no dots (.).
The token needs to be in JWS or JWE Compact Serialization Format. (JWS):
EncodedHeader.EndcodedPayload.EncodedSignature'. (JWE):
'EncodedProtectedHeader.EncodedEncryptedKey.EncodedInitializationVector.EncodedCiphertext.EncodedAuthenticationTag'.

Although, when I copied my JWT to jwt.io site, it was parsed nicely.

And then found this thread on aspnetcore issues.

From there I learned that after moving to .net 8.0 some people explicitly added Microsoft.IdentityModel.JsonWebTokens NuGet package to their projects. Tried that, and it fixed the solution.

I hope this thread helps other people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants