Giter Site home page Giter Site logo

Comments (7)

jpadilla avatar jpadilla commented on July 28, 2024

@cancan101 I guess that seems like a workaround that might be unnecessary. Will you not need those users then? Would just verifying and extracting the payload suffice? What's the end goal you're trying to accomplish?

from django-rest-framework-jwt.

cancan101 avatar cancan101 commented on July 28, 2024

Maybe a better question is how do I get access to all of the IsAuthenticated machinery in Django/DRF without actually creating User objects?

There is also the side benefit of now being able to use the User model to track the actions of this user.

from django-rest-framework-jwt.

jpadilla avatar jpadilla commented on July 28, 2024

In that case I think you might need to do a bit of work and might even be better off not using this package. Authentication classes in DRF expect a tuple to be returned and it will assign it to request.user and request.auth if I'm not mistaken.

You might also need a custom Permission class that doesn't depend on a user in the request for your other endpoints.

from django-rest-framework-jwt.

cancan101 avatar cancan101 commented on July 28, 2024

So then, why not just create the User?

from django-rest-framework-jwt.

jpadilla avatar jpadilla commented on July 28, 2024

@cancan101 that'll definitely be easier, yes.

from django-rest-framework-jwt.

jpadilla avatar jpadilla commented on July 28, 2024

Closing this for lack of activity. Will reopen if there are concrete actions for a next step.

from django-rest-framework-jwt.

cancan101 avatar cancan101 commented on July 28, 2024

I ended up solving this my overriding authenticate_credentials to look something like:

    def authenticate_credentials(self, payload):
        User = utils.get_user_model()
        user_id = jwt_get_user_id_from_payload(payload)
        if user_id is not None:
            user, created = User.objects.get_or_create(user_id=user_id)
...

from django-rest-framework-jwt.

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.