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.

Introspection does not work in .net 6.0

See original GitHub issue

Dear developers 😃

Thank you for the introspection auth handler for asp.net. Sadly, I’m experiencing a weird behaviour: I try to use the handler to authenticate against a local “oidc-provider” instance (nodejs). The provider delivers an opaque (reference) token. That’s the reason for the oauth2introspection handler.

With the following config:

builder.Services
    .AddAuthentication("token")
    .AddOAuth2Introspection("token", o =>
    {
        o.Authority = builder.Configuration.GetSection("Oidc").GetValue<string>("Issuer");
        o.ClientId = "wire-pact";
        o.ClientSecret = "demo-oidc-provider";
    });

I only receive the following log messages:

dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005]
      Endpoint 'OidcApi.Controllers.SwapiController.GetPeople (OidcApi)' with route pattern 'swapi/people' is valid for the request path '/swapi/people'
dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[1]
      Request matched endpoint 'OidcApi.Controllers.SwapiController.GetPeople (OidcApi)'
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]
      Authorization failed. These requirements were not met:
      DenyAnonymousAuthorizationRequirement: Requires an authenticated user.
info: IdentityModel.AspNetCore.OAuth2Introspection.OAuth2IntrospectionHandler[12]
      AuthenticationScheme: token was challenged.
dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[9]
      Connection id "0HMGCSJFNL7LQ" completed keep alive response.
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/1.1 GET http://localhost:5000/swapi/people - - - 401 0 - 7.3836ms

I made the config according to the docs: https://docs.duendesoftware.com/identityserver/v6/apis/aspnetcore/reference/

What did I do wrong? 😃

Could you give any hint where my errors are? Regards

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
brockallencommented, Mar 23, 2022

Yea, it’s strange that Microsoft throws in the UseAuthorization in their templates, but omit UseAuthetication. It’s sort of like “duh”. shrug

1reaction
buehlercommented, Mar 23, 2022

Holy moly. THANK YOU! @brockallen I’m sorry. Should’ve seen that.

Thank you 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet core IdentityModel will not introspect tokens
1 Answer 1 · 1. Has anyone been able to get this working? I am running into the same problem. Tokens are being...
Read more >
What's new in ASP.NET Core 6.0
This article highlights the most significant changes in ASP.NET Core 6.0 with links to relevant documentation.
Read more >
Protect dotnet Core webapi with OAuth Introspection
I am trying to build a bespoke DotNet Core web API protected by ISVaaS, using OAuth introspection. I've had problems getting the native ......
Read more >
You must either set Authority or IntrospectionEndpoint #1627
I'm sending a jwt so it seems to me that the back channel communication is not necessary and thus the secret shouldn't be...
Read more >
Flexible Access Token Validation in ASP.NET Core
To solve the problem, we created a brand new authentication handler that acts like a decorator over the JWT and introspection handler.
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