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.

OpenIdConnect: setting the ClaimsIssuer property in configuration options has no effect

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using the package Microsoft.AspNetCore.Authentication.OpenIdConnect in an ASP.NET Core application to add external login providers supporting OpenId Connect protocol, setting the ClaimsIssuer property in OpenIdConnectOptions has no effect; the principal claims still get generated with the issuer that comes from the external identity provider.

This behavior is in contrast with other social media login providers (Microsoft Account, Facebook, Google, etc.) where specifying this property in the configuration options would cause the principal claims to be issued with the specified claims issuer.

Is is possible to fix that so the ClaimsIssuer option in the OpenId Connect client works the same way it does in other social login provider packages? That way we can use it for any external identity provider that supports the OpenId Connect protocol but does not have a specific package built for it.

Expected Behavior

Once the ClaimsIssuer property of the OpenIdConnectOptions is set, the principal claims should be issued with the specified claims issuer.

Steps To Reproduce

  1. Configure the OpenIdConnect client with any identity provider that supports OpenId Connect;
  2. Set the ClaimsIssuer property to something different (e.g. “MyCustomIssuer”) in .AddOpenIdConnect() configuration;
  3. Verify that the actual issuer of the principal claims is unchanged.

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
Tratchercommented, Nov 28, 2022

Workaround:

    private class IssuerFixupAction : ClaimAction
    {
        public IssuerFixupAction() : base(ClaimTypes.NameIdentifier, string.Empty) { }

        public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer)
        {
            var oldClaims = identity.Claims.ToList();
            foreach (var claim in oldClaims)
            {
                identity.RemoveClaim(claim);
                identity.AddClaim(new Claim(claim.Type, claim.Value, claim.ValueType, issuer, claim.OriginalIssuer, claim.Subject));
            }
        }
    }


        services.AddAuthentication(...).AddCookie().AddOpenIdConnect(o =>
        {
           // ...
            o.ClaimsIssuer = "MyCustomIssuer";
            o.ClaimActions.Add(new IssuerFixupAction());
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to specify Claims Issuer · Issue #571 · openiddict/ ...
When settings options I have tried to override the claims issuer but it seems as if the setting is being ignored. services.
Read more >
ASP.NET Core 2: Intermittent Correlation Failed Errors
I do have a HAR where the intermittent problem does not occur… ... OpenIdConnect.Nonce. ... Configure the Claims Issuer to be Auth0 options....
Read more >
ASP.Net Core 2.1 with OpenID Connect: Correlation state ...
AspNetCore.Correlation. state property not found. Do you have more than one OIDC handler in DI and you don't set a unique callback path...
Read more >
OpenIdConnectOptions Class (Microsoft.AspNetCore. ...
This property is not set by default. In this case, an exception is thrown if an access_denied response is returned by the remote...
Read more >
OpenID Connect (OIDC) configuration properties
As a Quarkus developer, you configure the Quarkus OpenID Connect (OIDC) extension ... This property will have no effect when JWT tokens have...
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