Git Product home page Git Product logo

Comments (11)

mitsuhiko avatar mitsuhiko commented on August 23, 2024

Itsdangerous is a separate library and has nothing to do with django. Definitely not going to add magic that kicks in if the library is used in a certain environment.

from itsdangerous.

fletom avatar fletom commented on August 23, 2024

It's not quite true that it has "nothing to do with Django". The API and much of the implementation is derived directly from Django's code. That's besides the point though.

I admit that that kind of magic might not be the best way to do it.

However, what about my alternative suggestion about being able to set a default secret key? It's quite inconvenient, if you happen to be using Django just for one example, to have to pass the same key everywhere you use a signer.

It's really a violation of DRY to not have such a feature. What are your thoughts? Should I open a different ticket for it, or do you want to change the title of this one?

from itsdangerous.

mitsuhiko avatar mitsuhiko commented on August 23, 2024

It's really a violation of DRY to not have such a feature.

The solution that the flask ecosystem has is to make bridge libraries (Flask-SQLAlchemy for isntance) that preconfigures the library for the framework.

from itsdangerous.

mitsuhiko avatar mitsuhiko commented on August 23, 2024

On an aside: the API and implementation of itsdangerous has nothing in common with Django anymore.

from itsdangerous.

fletom avatar fletom commented on August 23, 2024

I really don't think I should need a bridge library (which wouldn't be easy to implement anyways), in order to have a default key. This is a very general feature. I don't need to bridge itsdangerous with Django or anything specific, it's just a global default for a certain value. Such a feature would be very useful no matter what framework you're using.

It's very convenient to have a global secret key, and then these pseudo-salts for each specific use of signing. It's much better than having different secrets for each, and I think that itsdangerous should facilitate doing it that way.

from itsdangerous.

mitsuhiko avatar mitsuhiko commented on August 23, 2024

There is not going to be a magic default to pick a secret key. There is no sane way to find the secret key for the library by itself.

from itsdangerous.

fletom avatar fletom commented on August 23, 2024

I think perhaps you're misunderstanding my suggestion. Forget the magic config for Django idea. I just want the option to tell itsdangerous at the module level what secret key to use by default.

e.g.

import itsdangrous
itsdangerous.DEFAULT_SECRET = '...'

If I'm using Django:

from django.core.conf import settings
import itsdangerous
itsdangerou.DEFAULT_SECRET = settings.SECRET_KEY

from itsdangerous.

mitsuhiko avatar mitsuhiko commented on August 23, 2024

I am not going to add global state and monkey patching to my libraries. I have been arguing against this dangerous anti pattern for years :-)

Not going to happen.

from itsdangerous.

fletom avatar fletom commented on August 23, 2024

Well I won't try to tell you what to do with your own project, but what alternative do you recommend in order to keep things DRY?

from itsdangerous.

mitsuhiko avatar mitsuhiko commented on August 23, 2024

As mentioned the solution is to use framework style integration libraries. That's exactly what Flask extensions are doing.

from itsdangerous.

fletom avatar fletom commented on August 23, 2024

In my opinion, that is inelegant and overly complex in the extreme. We can leave it at that disagreement though, thanks for your time on this.

from itsdangerous.

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.