Split Config

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-08-04 20:45:21 +02:00
parent 91e635eae5
commit 4ff71312f9
8 changed files with 154 additions and 57 deletions

View File

@@ -26,6 +26,16 @@ type (
DisableSignup bool `json:"disable-signup"`
}
trustAuthConfig struct {
CookieName string `json:"cookie-name"`
CookieDomain string `json:"cookie-domain"`
CookieDuration int `json:"cookie-duration"`
TokenDuration int `json:"token-duration"`
TokenSecret string `json:"token-secret"`
Scope string `json:"scope"`
TokenType string `json:"token-type"`
}
cookieConfig struct {
Domain string `json:"domain"`
Secret string `json:"secret"`
@@ -76,3 +86,22 @@ func (c authConfig) GetCookieSecretBytes() ([]byte, error) {
return []byte(c.Cookie.Secret), nil
}
func (c trustAuthConfig) GetTokenSecretBytes() ([]byte, error) {
if c.TokenSecret == "" {
return nil, fmt.Errorf("token secret cannot be empty")
}
if decoded, err := base64.StdEncoding.DecodeString(c.TokenSecret); err == nil {
if len(decoded) < 32 {
return nil, fmt.Errorf("decoded token secret must be at least 32 bytes long")
}
return decoded, nil
}
if len(c.TokenSecret) < 32 {
return nil, fmt.Errorf("token secret must be at least 32 bytes long")
}
return []byte(c.TokenSecret), nil
}