Changeset 0.29.0 (#195)
This commit is contained in:
@@ -57,3 +57,40 @@ func (s *GlobalConfigStore) GetAll(ctx context.Context) (map[string]models.JSONM
|
||||
}
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
||||
// ── OIDC state (v0.29.0-cs4) ────────────────────────────────────────────
|
||||
|
||||
func (s *GlobalConfigStore) SaveOIDCState(ctx context.Context, state, nonce, redirectTo string) error {
|
||||
_, err := DB.ExecContext(ctx, `
|
||||
INSERT INTO oidc_auth_state (state, nonce, redirect_to) VALUES ($1, $2, $3)
|
||||
`, state, nonce, redirectTo)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *GlobalConfigStore) ConsumeOIDCState(ctx context.Context, state string) (string, string, error) {
|
||||
var nonce, redirectTo string
|
||||
err := DB.QueryRowContext(ctx, `
|
||||
SELECT nonce, COALESCE(redirect_to, '') FROM oidc_auth_state WHERE state = $1
|
||||
`, state).Scan(&nonce, &redirectTo)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
// Delete (one-time use)
|
||||
_, _ = DB.ExecContext(ctx, `DELETE FROM oidc_auth_state WHERE state = $1`, state)
|
||||
return nonce, redirectTo, nil
|
||||
}
|
||||
|
||||
func (s *GlobalConfigStore) CleanupOIDCState(ctx context.Context) error {
|
||||
_, err := DB.ExecContext(ctx,
|
||||
`DELETE FROM oidc_auth_state WHERE created_at < NOW() - INTERVAL '10 minutes'`)
|
||||
return err
|
||||
}
|
||||
|
||||
// ── CS6 additions (v0.29.0) ─────────────────────────────────────────────
|
||||
|
||||
func (s *GlobalConfigStore) GetString(ctx context.Context, key string) (string, error) {
|
||||
var val string
|
||||
err := DB.QueryRowContext(ctx,
|
||||
"SELECT value FROM global_settings WHERE key = $1", key).Scan(&val)
|
||||
return val, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user