|
|
@ -120,18 +120,20 @@ func loadOAuth2From(rootCfg ConfigProvider) { |
|
|
|
OAuth2.JWTSigningPrivateKeyFile = filepath.Join(AppDataPath, OAuth2.JWTSigningPrivateKeyFile) |
|
|
|
OAuth2.JWTSigningPrivateKeyFile = filepath.Join(AppDataPath, OAuth2.JWTSigningPrivateKeyFile) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
key := make([]byte, 32) |
|
|
|
if InstallLock { |
|
|
|
n, err := base64.RawURLEncoding.Decode(key, []byte(OAuth2.JWTSecretBase64)) |
|
|
|
key := make([]byte, 32) |
|
|
|
if err != nil || n != 32 { |
|
|
|
n, err := base64.RawURLEncoding.Decode(key, []byte(OAuth2.JWTSecretBase64)) |
|
|
|
key, err = generate.NewJwtSecret() |
|
|
|
if err != nil || n != 32 { |
|
|
|
if err != nil { |
|
|
|
key, err = generate.NewJwtSecret() |
|
|
|
log.Fatal("error generating JWT secret: %v", err) |
|
|
|
if err != nil { |
|
|
|
} |
|
|
|
log.Fatal("error generating JWT secret: %v", err) |
|
|
|
|
|
|
|
} |
|
|
|
secretBase64 := base64.RawURLEncoding.EncodeToString(key) |
|
|
|
|
|
|
|
rootCfg.Section("oauth2").Key("JWT_SECRET").SetValue(secretBase64) |
|
|
|
secretBase64 := base64.RawURLEncoding.EncodeToString(key) |
|
|
|
if err := rootCfg.Save(); err != nil { |
|
|
|
rootCfg.Section("oauth2").Key("JWT_SECRET").SetValue(secretBase64) |
|
|
|
log.Fatal("save oauth2.JWT_SECRET failed: %v", err) |
|
|
|
if err := rootCfg.Save(); err != nil { |
|
|
|
|
|
|
|
log.Fatal("save oauth2.JWT_SECRET failed: %v", err) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|