Skip to content

Add a method to mark settings as sensitive with patterns #6

@grimmy

Description

@grimmy

There should be a way to make settings sensitive, so that I can get a userfacing copy of them without giving out secrets. For example, so I have something like:

OAUTH2_PROVIDER_TOKEN: 'abc3b45b2b2b6b89099987399bacdfe23fde'

I would like to know that the key exists to show it on a health endpoint or some other mechanism to verify that it's configured. I was thinking something like:

@sensitive
OAUTH2_PROVIDER_TOKEN: 'abc3b45b2b2b6b89099987399bacdfe23fde'

and then something like this would work.

 >>> import settings
 >>> print(settings.OAUTH2_PROVIDER_TOKEN)
 **************

However, I also have settings that are uris, so I need a way to pattern match them and hide at the very least the password, but probably the username as well. So something like this would rock:

@sensitive_uri
REDIS=redis://user:pass@host/db

Which would result in

>>> import settings
>>> print(settings.REDIS)
redis://***:***@host/db

I think there would be value in just being able to pass a regex as well where all groups would be starred out, but I can't come up with an example right now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions