mirror of
https://github.com/thomiceli/opengist.git
synced 2025-07-12 19:01:50 +02:00
Allow to define secret key & move the secret key file to parent directory (#358)
This commit is contained in:
@ -6,10 +6,12 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func GenerateSecretKey(filePath string) []byte {
|
||||
// GenerateSecretKey generates a new secret key for sessions
|
||||
// Returns the key and a boolean indicating if the key was generated
|
||||
func GenerateSecretKey(filePath string) ([]byte, bool) {
|
||||
key, err := os.ReadFile(filePath)
|
||||
if err == nil {
|
||||
return key
|
||||
return key, false
|
||||
}
|
||||
|
||||
key = securecookie.GenerateRandomKey(32)
|
||||
@ -22,5 +24,5 @@ func GenerateSecretKey(filePath string) []byte {
|
||||
log.Fatal().Err(err).Msgf("Failed to save the key to %s", filePath)
|
||||
}
|
||||
|
||||
return key
|
||||
return key, true
|
||||
}
|
||||
|
Reference in New Issue
Block a user