forked from forgejo/forgejo
Port "Use general token signing secret"
Port of https://github.com/go-gitea/gitea/pull/29205 Use a clearly defined "signing secret" for token signing. (cherry picked from commit 8be198cdef0a486f417663b1fd6878458d7e5d92)
This commit is contained in:
parent
cfd6420a0e
commit
62d3e5255f
13 changed files with 131 additions and 61 deletions
|
@ -300,7 +300,7 @@ func InitSigningKey() error {
|
|||
case "HS384":
|
||||
fallthrough
|
||||
case "HS512":
|
||||
key, err = loadSymmetricKey()
|
||||
key = setting.GetGeneralTokenSigningSecret()
|
||||
case "RS256":
|
||||
fallthrough
|
||||
case "RS384":
|
||||
|
@ -333,12 +333,6 @@ func InitSigningKey() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// loadSymmetricKey checks if the configured secret is valid.
|
||||
// If it is not valid, it will return an error.
|
||||
func loadSymmetricKey() (any, error) {
|
||||
return util.Base64FixedDecode(base64.RawURLEncoding, []byte(setting.OAuth2.JWTSecretBase64), 32)
|
||||
}
|
||||
|
||||
// loadOrCreateAsymmetricKey checks if the configured private key exists.
|
||||
// If it does not exist a new random key gets generated and saved on the configured path.
|
||||
func loadOrCreateAsymmetricKey() (any, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue