-
-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datasette secret mechanism - initially for signed cookies #785
Comments
I previously solved this for the
|
That |
Maybe Datasette should have a |
I'm going to use https://github.com/pallets/itsdangerous for this. Annoyingly they're very close to release v2.0 which adds support for key rotation... but it's not quite out of pre-release yet. I'll go with 1.1.0 for the moment and upgrade to 2.0 as soon as that is out. |
First version of cookie signing will use a secret that is either pulled from |
... actually no I'll do it using a CLI option that can also be in an environment variable: https://click.palletsprojects.com/en/7.x/options/#values-from-environment-variables @click.command()
@click.option('--secret', envvar='DATASETTE_SECRET')
def greet(secret):
... |
I'll add two utility methods to the Datasette class:
|
Documentation for those new methods: https://github.com/simonw/datasette/blob/e28207e76ec3b26b2c396370fd3fb325a60bfd49/docs/internals.rst#signvalue-namespacedefault |
This is nearly ready to close. I'm going to add documentation for |
I'll add a section about secrets to this page: https://datasette.readthedocs.io/en/latest/config.html |
See comment in #784 (comment)
Datasette needs to be able to set signed cookies - which means it needs a mechanism for safely handling a signing secret.
Since Datasette is a long-running process the default behaviour here can be to create a random secret on startup. This means that if the server restarts any signed cookies will be invalidated.
If the user wants a persistent secret they'll have to generate it themselves - maybe by setting an environment variable?
The text was updated successfully, but these errors were encountered: