Skip to content
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

Generate secret key during first run and store it in the database #4

Open
traverseda opened this issue Apr 4, 2021 · 5 comments
Open

Comments

@traverseda
Copy link
Contributor

Realistically the user never needs to care about the secret key, it can be auto-generated during the first run. I think it makes sense to put it in the database and not the file system because that way if you use a distributed database backend like cockroachDb every node gets the same secret key and everything sort of just works.

import secrets
secret_key=secrets.token_urlsafe(50)

Is part of the standard library.

Just removes a little bit more friction when people set up the service for the first time.

@sonicnkt
Copy link
Owner

sonicnkt commented Apr 4, 2021

Good idea, i would put this in the settings table and create it with the first run function (empty db).
Do you think this should be exposed in the admin ui or can this be hidden?

@traverseda
Copy link
Contributor Author

It's only used internally so I don't think there's any point in exposing it to the end user. Worst case if you lose it is all the currently active user sessions get reset and people need to log in again.

@sonicnkt
Copy link
Owner

sonicnkt commented Apr 4, 2021

makes sense. will integrate this in the coming days.

@traverseda
Copy link
Contributor Author

Awesome, I'm going to go through this OpenId connect example and try to adapt it to your database models

https://github.com/authlib/example-oidc-server

@sonicnkt
Copy link
Owner

sonicnkt commented Apr 6, 2021

with the current app structure its no possible to load the key using the config object as the db would have to be initialized already.
Im wondering if its a bit of a secrutiy risk to store that in db as in no other example i have seen this is done this way.

I think i will put this aside for the moment and maybe add some instructions how to generate one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants