Stable oauth2.JWT_SECRET #106

Closed
opened 2021-01-28 05:27:11 +00:00 by viceice · 5 comments
Contributor

The oauth2.JWT_SECRET should be stable.

Currently it will be regenerated on each container restart. So all existing token are invalid then.

https://discourse.gitea.io/t/drone-auth-error-after-gitea-server-restart/2880/4

The `oauth2.JWT_SECRET` should be stable. Currently it will be regenerated on each container restart. So all existing token are invalid then. https://discourse.gitea.io/t/drone-auth-error-after-gitea-server-restart/2880/4
Author
Contributor

Maybe related to #43

Maybe related to #43
Member

Well, you can always define the oauth token yourself.
The same goes for #43. Should be stable if you've defined one :)

gitea:
  config:
    oauth2:
      JWT_SECRET: <your_secret>
    security:
      INTERNAL_TOKEN: <token>
Well, you can always define the oauth token yourself. The same goes for #43. Should be stable if you've defined one :) ```yaml gitea: config: oauth2: JWT_SECRET: <your_secret> security: INTERNAL_TOKEN: <token> ```
Author
Contributor

Sure, but the JWT_SECRET must have a specific structure, otherwise it will be overwritten on every gitea startup

0cd87d64ff/modules/setting/setting.go (L760)

Seems need exacly 32 bytes (then base64 encoded)

fe79b13ab2/modules/generate/generate.go (L60-L68)

Sure, but the `JWT_SECRET` must have a specific structure, otherwise it will be overwritten on every gitea startup https://github.com/go-gitea/gitea/blob/0cd87d64ff8bb40520877d3a217363de299f4531/modules/setting/setting.go#L760 Seems need exacly 32 bytes (then base64 encoded) https://github.com/go-gitea/gitea/blob/fe79b13ab2ce9526fae10a5257b4e171cae30ecb/modules/generate/generate.go#L60-L68
Member

Maybe we could create those tokens (internal token, jwt_secret, secret_key) prior to the actual run. There are gitea cli commands to do that. We could even dynamically create a Kubernetes secret storing these values for the future. This would requires access to the Kubernetes API which could be done using a serviceaccount with the necessary permissions (e.g. update a specific secret that is created with the helm chart rollout in the cluster).

Doing so would persist those data in a secure way so that they can be reused.

What do you think @luhahn?

Maybe we could create those tokens (internal token, jwt_secret, secret_key) prior to the actual run. There are gitea cli commands to do that. We could even dynamically create a Kubernetes secret storing these values for the future. This would requires access to the Kubernetes API which could be done using a serviceaccount with the necessary permissions (e.g. update a specific secret that is created with the helm chart rollout in the cluster). Doing so would persist those data in a secure way so that they can be reused. What do you think @luhahn?
Member

I am sure this issue will be fixed with #239, once ready.

I am sure this issue will be fixed with #239, once ready.
justusbunsi added the
kind
bug
label 2021-11-13 12:38:17 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/helm-chart#106
No description provided.