fix: comprehensive security, performance, and quality hardening
Security: apply AdminOnly middleware to mutating routes, require ENCRYPTION_KEY and ADMIN_PASSWORD (no insecure defaults), restrict CORS to same-origin, fix OIDC token delivery via cookie instead of URL query param, add rate limiting on login, add MaxBytesReader, validate volume paths against traversal, add security headers, validate user roles, add Secure flag to OIDC cookie. Performance: set SQLite MaxOpenConns(1) to prevent SQLITE_BUSY, add FK indexes on 8 columns, track notifier goroutines with WaitGroup for graceful shutdown, use GetRegistryByName instead of GetAllRegistries in deployer, pass basePath param to avoid redundant settings query, return empty slices from store to remove reflection. Quality: refactor TriggerDeploy to delegate to runDeploy (~100 lines removed), consolidate duplicated utilities (extractPort, boolToInt, now, isTerminalStatus) into shared exports, migrate all log.Printf to slog structured logging, use consistent webhook response envelope, remove dead code (parseEnvVars, duplicate auth types). UX: clean up NPM proxy on instance removal via API, add README with quickstart guide, add .env.example, require ADMIN_PASSWORD in docker-compose, document staging-net prerequisite.
This commit is contained in:
@@ -2,26 +2,6 @@ package auth
|
||||
|
||||
import "time"
|
||||
|
||||
// User represents an authenticated user stored in the database.
|
||||
type User struct {
|
||||
ID string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
PasswordHash string `json:"-"`
|
||||
Email string `json:"email"`
|
||||
Role string `json:"role"` // admin, viewer
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
// AuthSettings holds the authentication configuration (single-row pattern).
|
||||
type AuthSettings struct {
|
||||
AuthMode string `json:"auth_mode"` // local, oidc
|
||||
OIDCClientID string `json:"oidc_client_id"`
|
||||
OIDCClientSecret string `json:"-"`
|
||||
OIDCIssuerURL string `json:"oidc_issuer_url"`
|
||||
OIDCRedirectURL string `json:"oidc_redirect_url"`
|
||||
}
|
||||
|
||||
// Claims represents the JWT token claims.
|
||||
type Claims struct {
|
||||
UserID string `json:"user_id"`
|
||||
|
||||
Reference in New Issue
Block a user