question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for UserInfo Message Level Encryption (Microsoft.AspNetCore.Authentication.OpenIdConnect)

See original GitHub issue

I am trying to authenticate my app against this authority and method that uses MLE (Message Level Encryption): https://developer.signicat.com/enterprise/docs/authentication/about-oidc.html#finnish-trust-network-ftn-specifics

Quote:

You should send your requests as a normal OIDC request (see exception below). The difference between a normal OIDC flow and MLE flow are:

The ID token and the response from user info is a nested JWT which is encrypted and signed. Decrypt it with your private key from the RSA pair given to Signicat. Deserialize the resulting signed JWT and verify the signature.

Extra emphasis on the “and the response from user info”.

I have managed to make the ID token handling to work by using a custom ISecurityTokenValidator like so:

options.SecurityTokenValidator = new SecurityTokenValidator();

However, your code fails when parsing the user token here, because the Payload is null (I guess because you need to decrypt the token to get the real payload):

https://github.com/dotnet/aspnetcore/blob/6427d9cc718f8093c506b62b6fd12544411b477f/src/Security/Authentication/OpenIdConnect/src/OpenIdConnectHandler.cs#L902

(Note: I am getting this error with version 3.1.0 of your Microsoft.AspNetCore.Authentication.OpenIdConnect library, but the code seems the same in newer versions)

Describe the solution you’d like

I guess you should provide a way to decrypt the user info token as well.

options.UserInfoTokenValidator = new SecurityTokenValidator();

Additional context

Any ideas for a workaround are welcome. I am trying to replace the OpenIdConnectHandler with my own version now, but I am not sure this is possible… 😦 Also, the event callback for OnUserInformationReceived is called too late to help me do something with the encrypted token, it seems.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Tratchercommented, Jun 12, 2021

@DumboJet I recommend not calling HandleResponse in this case. You shouldn’t need Success either, just let the event complete and the normal logic continue.

0reactions
DumboJetcommented, Jun 14, 2021

Thank you @Tratcher ! Indeed, your suggestion works! I had the impression it didn’t, but apparently I was wrong.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenIdConnectOptions Class (Microsoft.AspNetCore. ...
Gets or sets the method used to redirect the user agent to the identity provider. Authority. Gets or sets the Authority to use...
Read more >
Web sign in with OpenID Connect - B2C
OpenID Connect is an authentication protocol, built on top of OAuth 2.0, that can be used to securely sign users in to web...
Read more >
OpenIdConnectHandler Class
A per-request authentication handler for the OpenIdConnectAuthenticationMiddleware.
Read more >
Microsoft identity platform UserInfo endpoint
As part of the OpenID Connect (OIDC) standard, the UserInfo endpoint returns information about an authenticated user.
Read more >
ASP.NET Core breaking changes for versions 3.0 and 3.1
Lists the breaking changes in ASP.NET Core 3.0 and 3.1. ... The changes impact remote authentication scenarios, such as OpenID Connect and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found