Giter Site home page Giter Site logo

Add env.secret about environs HOT 9 CLOSED

sloria avatar sloria commented on May 16, 2024
Add env.secret

from environs.

Comments (9)

sloria avatar sloria commented on May 16, 2024 1

An alternative to env.secret would be to allow any casted value to be secret.

SECRET_BOOL = env.bool('MY_PRECIOUS', secret=True)

print(SECRET_BOOL)  # => "*******"
print(SECRET_BOOL.value)  # => True

from environs.

sloria avatar sloria commented on May 16, 2024

Hold on this until encode/starlette#301 is resolved.

from environs.

al-the-x avatar al-the-x commented on May 16, 2024

Excellent work on this lib. Seems that this issue is "resolved" in your PR encode/starlette#303

from environs.

sloria avatar sloria commented on May 16, 2024

Thanks, I'm aware. I'll have to give this more thought. I think if we add this to environs, we'll go with the .value approach suggested in encode/starlette#301.

Feedback welcome!

from environs.

ribeaud avatar ribeaud commented on May 16, 2024

Related to this, it would be nice to be able to store encrypted values which would then be automatically decrypted by the library when needed and up to a previously specified master password. Something similar to http://www.jasypt.org/encrypting-configuration.html in Java.

To be identified such values would be surrounded by ENC(...) for instance. As a rule of thumb passwords should never be checked-in. But with such a mechanism, this is then acceptable.

Currently I am working with a custom parser to handle such cases.

from environs.

sloria avatar sloria commented on May 16, 2024

Encryption seems outside the scope of environs. environs is used for parsing values that are not checked into source control. If you do need encryption you can do so after parsing, e.g.

PASSWORD = decrypt(env.str('PASSWORD'))

from environs.

al-the-x avatar al-the-x commented on May 16, 2024

Or use a custom parser that handles your specific encryption:

@env.parser_for('encrypted')
def encrypted_value(value):
  return decrypt(value)

password = env.encrypted('PASSWORD')

from environs.

sloria avatar sloria commented on May 16, 2024

A custom parser also works but doesn't allow composition.

from environs.

sloria avatar sloria commented on May 16, 2024

Closing for lack of interest

from environs.

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.