Giter Site home page Giter Site logo

Comments (5)

ramax495 avatar ramax495 commented on August 27, 2024

Check values of claim constants.
When you create a token you use JwtRegisteredClaimNames.Sub constant with value "sub".
And when you get claim in CurrentUser service you use ClaimTypes.NameIdentifier and its value is "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"

from cleanarchitecture.

salmanshafiq00 avatar salmanshafiq00 commented on August 27, 2024

NameIdentifier bind the Sub type value.

Also, more clearify, I added another Claim to jwt which is "uid" claim type.

Here, is my decoded token value in jwt
image

Little bit change in CurrentUser class
image

still, user of httpcontext shows null
image

is there any possibility that when i request with Bearer token, the action can't verify bearer token?

but i get the bearer token in request header.
image

from cleanarchitecture.

iamcymentho avatar iamcymentho commented on August 27, 2024

Hello @salmanshafiq00, your solution looks promising, and I'd like to investigate the null issue you encountered. Could you please push your implementation to the repository so that I can clone it and examine the code more closely? This will help me better understand the problem and assist with finding a resolution. Thank you!

from cleanarchitecture.

Chris-Mingay avatar Chris-Mingay commented on August 27, 2024

@salmanshafiq00 I've been wrestling with similar in an effort to implement a more 'vanilla' JWT and I believe it's because the system isn't recognising your DefaultAuthenticationScheme and because of it, is not calling the [Authorize] attribute in the way you'd expect.

I believe you can decorate controllers with:

[Authorize(AuthenticationSchemes = "Bearer")]

I had thought I had set the authentication scheme in the way I set up identity but it doesn't seem to translate. I'll add more when/if

from cleanarchitecture.

salmanshafiq00 avatar salmanshafiq00 commented on August 27, 2024

@iamcymentho @Chris-Mingay ,
For your concern I push my repo in GitHub and here is the link https://github.com/salmanshafiq00/LMS

from cleanarchitecture.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.