mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-18 22:49:52 +02:00
feat(oidc): support token refreshing via offline_access scope
- refactored code - moved api/v1/auth to auth/ - security enhancement - env example update - default jwt ttl changed to 24 hours
This commit is contained in:
@@ -23,6 +23,8 @@ const (
|
||||
ComposeFileName = "compose.yml"
|
||||
ComposeExampleFileName = "compose.example.yml"
|
||||
|
||||
DataDir = "data"
|
||||
|
||||
ErrorPagesBasePath = "error_pages"
|
||||
|
||||
AgentCertsBasePath = "certs"
|
||||
|
||||
@@ -13,7 +13,7 @@ func decodeJWTKey(key string) []byte {
|
||||
}
|
||||
bytes, err := base64.StdEncoding.DecodeString(key)
|
||||
if err != nil {
|
||||
log.Panic().Err(err).Msg("failed to decode jwt key")
|
||||
log.Fatal().Str("key", key).Err(err).Msg("failed to decode secret")
|
||||
}
|
||||
return bytes
|
||||
}
|
||||
@@ -22,7 +22,7 @@ func RandomJWTKey() []byte {
|
||||
key := make([]byte, 32)
|
||||
_, err := rand.Read(key)
|
||||
if err != nil {
|
||||
log.Panic().Err(err).Msg("failed to generate random jwt key")
|
||||
log.Fatal().Err(err).Msg("failed to generate random jwt key")
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ var (
|
||||
|
||||
APIJWTSecure = GetEnvBool("API_JWT_SECURE", true)
|
||||
APIJWTSecret = decodeJWTKey(GetEnvString("API_JWT_SECRET", ""))
|
||||
APIJWTTokenTTL = GetDurationEnv("API_JWT_TOKEN_TTL", time.Hour)
|
||||
APIJWTTokenTTL = GetDurationEnv("API_JWT_TOKEN_TTL", 24*time.Hour)
|
||||
APIUser = GetEnvString("API_USER", "admin")
|
||||
APIPassword = GetEnvString("API_PASSWORD", "password")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user