-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
It should be possible to provide a file to LFS_JWT_SECRET #25034
Comments
I do not have Go experience, but could try implementing this as it seems simple enough, as long as someone can review my changes |
Excellent idea. Two points:
Ideally we should have file secrets for all four secrets. But how do we deal with the second point? (How did you do it?) |
@lonix1 two have the URI as an option. As well, if you are using the docker image, then all of them are, in theory, available as reading from a file if using env vars. |
Thanks, you are right! I was probably looking at an old
I assume you mean this?... EDIT: actually, by putting them into env vars, it's a bad idea. They could get logged. |
Make environment-to-ini support loading key value from file #24832 |
Thank you very much @wxiaoguang for your advice. But I'm struggling to understand that PR (I'm not a go developer). Is there an example how to use it? |
It's for docker users. See the documents.
|
Oh! 😄 Ok, that is what we were talking about above. But as I said there, keeping secrets in environment variables is a bad idea. Sometimes it's the only option though. @varanauskas is right, we should have four file-based options for the four secrets. But we need to consider that there is no good way to load them into the app, without leaking secrets. Maybe env vars is the only way, I hope there is a better way. |
Sorry I didn't get your point. See:
They are indeed able to be stored in your file. |
Sorry @wxiaoguang, I didn't see that part. So we can do this:
# ...
environment:
GITEA__server__LFS_JWT_SECRET__FILE: /LFS_JWT_SECRET
GITEA__security__INTERNAL_TOKEN__FILE: /INTERNAL_TOKEN
GITEA__security__SECRET_KEY__FILE: /SECRET_KEY
GITEA__oauth2__JWT_SECRET__FILE: /JWT_SECRET
volumes:
- ./INTERNAL_TOKEN:/INTERNAL_TOKEN:ro
- ./JWT_SECRET:/JWT_SECRET:ro
- ./LFS_JWT_SECRET:/LFS_JWT_SECRET:ro
- ./SECRET_KEY:/SECRET_KEY:ro
Is that what you mean? |
Yes, it should work this way. If it doesn't work, feel free to open an issue for it (with reproducible steps) |
@wxiaoguang Thanks! That is very good news. @varanauskas I am going to do it this way. I will let you know my results. |
My findings are here. |
Update TL;DR: So @varanauskas proposal is still good:
To avoid the "leaking secrets by logging env vars" problem, the solution:
|
I can understand your meaning but I can't understand why it is a problem. The
I do not understand why If there is anyone who can read |
Thanks @wxiaoguang you are right. You help me a lot today. So there are
|
It is my understanding environment-to-ini modifies the app.ini file. This unfortunately does not fit my use case, what I want to do is this:
thus option of secrets being added to app.ini from env automatically do not fit this use case |
@varanauskas Agreed, I have the same use case. The env-to-ini option writes to the So we need your idea of (I have a compromise solution which keeps secrets out of version control, but I'm using automation (ansible). I'm unsure of your approach to deployment.) |
Exactly I also use Ansible |
Actually, unlike other secrets, this "LFS_JWT_SECRET" do not need to be pre-generated. You can keep it empty, then when Gitea starts, the secret will be generated automatically. |
Is it okay if LFS_JWT_SECRET is different on each boot with Same db and sessions? |
If you also use ansible, this is my compromise until there is a better way:
The implications of this are:
I wish there were a better way. But I tried all the other ways and they weren't as good:
|
I think it is OK because the LFS_JWT_SECRET is a short-live token for LFS operations. Each token is re-generated for each |
I've implemented the other secrets to be able to be loaded via URI in the linked PR. If anyone want to test it that would be appreciated :) |
I can try find ttime to test it, which version must I get? |
@lonix1 the nightly version would have it. either the binary https://dl.gitea.com/gitea/main/ or the |
Feature Description
TLDR:
LFS_JWT_SECRT
should be able to be stored in a separate file outlined by outlined byLFS_JWT_SECRET_URI
Secrets in the
[security]
section of config allow providing both an inline secret as well as a file where the secret is stored with the_URI
suffix.For example
This allows for better installation/maintenance of Gitea, as /etc/gitea/app.ini could be stored in version control, as all secrets would be outlined separately.
Proposal:
I propose adding a new config key
LFW_JWT_SECRET_URI
that would work the same asINTERNAL_TOKEN_URI
by allowing users to specify a separate file where theLFS_JWT_SECRET
is storedScreenshots
No response
The text was updated successfully, but these errors were encountered: