diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-02-16 23:18:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-16 15:18:30 +0000 |
commit | 45c15387b292c25b5d0572b2eb3f85414156372a (patch) | |
tree | cb3052845543958872adcab501c87871502a525e /modules/setting/lfs.go | |
parent | 7132a0ba75d6fe734d9f950f217a5ceb81375328 (diff) | |
download | gitea-45c15387b292c25b5d0572b2eb3f85414156372a.tar.gz gitea-45c15387b292c25b5d0572b2eb3f85414156372a.zip |
Refactor JWT secret generating & decoding code (#29172)
Old code is not consistent for generating & decoding the JWT secrets.
Now, the callers only need to use 2 consistent functions:
NewJwtSecretWithBase64 and DecodeJwtSecretBase64
And remove a non-common function Base64FixedDecode from util.go
Diffstat (limited to 'modules/setting/lfs.go')
-rw-r--r-- | modules/setting/lfs.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/modules/setting/lfs.go b/modules/setting/lfs.go index a5ea537cef..22a75f6008 100644 --- a/modules/setting/lfs.go +++ b/modules/setting/lfs.go @@ -4,12 +4,10 @@ package setting import ( - "encoding/base64" "fmt" "time" "code.gitea.io/gitea/modules/generate" - "code.gitea.io/gitea/modules/util" ) // LFS represents the configuration for Git LFS @@ -62,9 +60,9 @@ func loadLFSFrom(rootCfg ConfigProvider) error { } LFS.JWTSecretBase64 = loadSecret(rootCfg.Section("server"), "LFS_JWT_SECRET_URI", "LFS_JWT_SECRET") - LFS.JWTSecretBytes, err = util.Base64FixedDecode(base64.RawURLEncoding, []byte(LFS.JWTSecretBase64), 32) + LFS.JWTSecretBytes, err = generate.DecodeJwtSecretBase64(LFS.JWTSecretBase64) if err != nil { - LFS.JWTSecretBytes, LFS.JWTSecretBase64, err = generate.NewJwtSecretBase64() + LFS.JWTSecretBytes, LFS.JWTSecretBase64, err = generate.NewJwtSecretWithBase64() if err != nil { return fmt.Errorf("error generating JWT Secret for custom config: %v", err) } |