middleware

package
v0.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionCookieName = "overwatch_session"
)

Variables

This section is empty.

Functions

func BearerAuth

func BearerAuth(next http.Handler) http.Handler

BearerAuth validates the Bearer token in the Authorization header

func CORS

func CORS(next http.Handler) http.Handler

CORS adds CORS headers to the response

func ClearSessionCookie added in v0.0.5

func ClearSessionCookie(w http.ResponseWriter)

ClearSessionCookie clears the session cookie

func GetAllowedOrigins added in v0.0.5

func GetAllowedOrigins() []string

GetAllowedOrigins returns the list of allowed origins from environment Returns empty slice if ALLOWED_ORIGINS is "*" or empty (allow all)

func IsOriginAllowed added in v0.0.5

func IsOriginAllowed(origin string) bool

IsOriginAllowed checks if an origin is in the allowed list

func SetSessionCookie added in v0.0.5

func SetSessionCookie(w http.ResponseWriter, token string)

SetSessionCookie sets the session cookie on the response

Types

type SessionAuth added in v0.0.5

type SessionAuth struct {
	// contains filtered or unexported fields
}

SessionAuth handles session-based authentication for the web UI

func NewSessionAuth added in v0.0.5

func NewSessionAuth() *SessionAuth

NewSessionAuth creates a new session auth handler

func (*SessionAuth) CreateSession added in v0.0.5

func (s *SessionAuth) CreateSession() (string, error)

CreateSession creates a new session and returns the session token

func (*SessionAuth) DestroySession added in v0.0.5

func (s *SessionAuth) DestroySession(token string)

DestroySession removes a session

func (*SessionAuth) IsEnabled added in v0.0.5

func (s *SessionAuth) IsEnabled() bool

IsEnabled returns true if password auth is configured

func (*SessionAuth) RequireSession added in v0.0.5

func (s *SessionAuth) RequireSession(next http.Handler) http.Handler

RequireSession is middleware that checks for a valid session cookie

func (*SessionAuth) ValidatePassword added in v0.0.5

func (s *SessionAuth) ValidatePassword(password string) bool

ValidatePassword checks if the provided password is correct

func (*SessionAuth) ValidateSession added in v0.0.5

func (s *SessionAuth) ValidateSession(token string) bool

ValidateSession checks if the session token is valid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL