Documentation
¶
Overview ¶
Package server provides the HTTP server and WebSocket handler for the web interface.
Index ¶
- func UpgradeConnection(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)
- type CommandHandler
- type SessionManager
- func (sm *SessionManager) AuthMiddleware(username, password string) func(http.HandlerFunc) http.HandlerFunc
- func (sm *SessionManager) Create() string
- func (sm *SessionManager) CreateCSRFToken() string
- func (sm *SessionManager) Delete(token string)
- func (sm *SessionManager) Login(w http.ResponseWriter, r *http.Request, ...) bool
- func (sm *SessionManager) Logout(w http.ResponseWriter, r *http.Request)
- func (sm *SessionManager) Validate(token string) bool
- func (sm *SessionManager) ValidateCSRFToken(token string) bool
- type WSCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UpgradeConnection ¶
UpgradeConnection upgrades an HTTP connection to WebSocket.
Types ¶
type CommandHandler ¶
type CommandHandler struct {
// contains filtered or unexported fields
}
CommandHandler processes WebSocket commands.
func NewCommandHandler ¶
func NewCommandHandler( cfg *config.Config, getState func() types.EncoderState, startOutput func(string) error, stopOutput func(string) error, restartEnc func() error, testTriggers map[string]func() error, ) *CommandHandler
NewCommandHandler creates a new command handler.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager handles user authentication sessions.
func NewSessionManager ¶
func NewSessionManager() *SessionManager
NewSessionManager creates a new session manager.
func (*SessionManager) AuthMiddleware ¶
func (sm *SessionManager) AuthMiddleware(username, password string) func(http.HandlerFunc) http.HandlerFunc
AuthMiddleware returns middleware that requires a valid session cookie. Unauthenticated requests are redirected to /login.
func (*SessionManager) Create ¶
func (sm *SessionManager) Create() string
Create creates a new session and returns the token.
func (*SessionManager) CreateCSRFToken ¶ added in v0.1.5
func (sm *SessionManager) CreateCSRFToken() string
CreateCSRFToken generates a new CSRF token.
func (*SessionManager) Delete ¶ added in v0.1.5
func (sm *SessionManager) Delete(token string)
Delete removes a session token.
func (*SessionManager) Login ¶ added in v0.1.5
func (sm *SessionManager) Login(w http.ResponseWriter, r *http.Request, username, password, configUser, configPass string) bool
Login validates credentials and creates a session if valid. Returns true if login succeeded. Uses constant-time comparison to prevent timing attacks.
func (*SessionManager) Logout ¶ added in v0.1.5
func (sm *SessionManager) Logout(w http.ResponseWriter, r *http.Request)
Logout clears the session cookie and deletes the session.
func (*SessionManager) Validate ¶
func (sm *SessionManager) Validate(token string) bool
Validate checks if a session token is valid.
func (*SessionManager) ValidateCSRFToken ¶ added in v0.1.5
func (sm *SessionManager) ValidateCSRFToken(token string) bool
ValidateCSRFToken checks if a CSRF token is valid and removes it.