Giter Club home page Giter Club logo

Comments (5)

aaugustin avatar aaugustin commented on July 29, 2024

Tying tokens to passwords is a security feature. From https://github.com/aaugustin/django-sesame#a-few-words-about-security:

Tokens are tied to the primary key and the password of the corresponding user. Changing the password invalidates the token.

From a security perspective, I'm uncomfortable with the idea of non-revocable tokens.

If had to to implement non-expiring tokens, I'd create a table of tokens with a one-to-one relationship with users. That would still allow removing or rotating a token.

That should take less than 50 lines of code: it requires a Token model, a post-save signal on User to create tokens, an admin to manage token and a middleware which can be largely borrowed from django-sesame. I would say it's a different project from django-sesame, though :-)

I'm keeing the issue open because I'd like to think a bit more about it and perhaps clarify the docs.

from django-sesame.

paterlinimatias avatar paterlinimatias commented on July 29, 2024

I agree that the majority of cases would be satisfied with your concept, but when you allow social login on your app you do not have a password. then if you want to set up a password, you end up resetting your token. It's probably not really common to use the magic links in bot conversations, but that's our case, and it became a big problem.
We'll figure it out, i just wanted a second opinion.

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

That's a valid use case and indeed one django-sesame doesn't handle very well.

I would find it acceptable to disable token invalidation on password change when SESAME_MAX_AGE is set — or perhaps if it's set to a low value (not more than a few days). If the token expires soon, then it can be reasonable not to invalidate it and simply wait for it to expire. A setting would opt-in to this behavior.

Mostly I'm trying to avoid Giving Users Guns Pointed At Feet :-) such as non-expiring, non-revocable tokens. (At worst you can always change SECRET_KEY but that's brutal).

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

I can add a setting that prevents token invalidation on password change, but would raise an error when SESAME_MAX_AGE isn't set.

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

Magic links seem to be a good use case of django-sesame.

I think the commit I just merged should do what you want.

(You don't get "eternal" tokens because that's a Big Gun Aimed At User's Feet.)

from django-sesame.

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.