Documentation
¶
Index ¶
- Constants
- func BearerAuth(next http.Handler) http.Handler
- func CORS(next http.Handler) http.Handler
- func ClearSessionCookie(w http.ResponseWriter)
- func GetAllowedOrigins() []string
- func IsOriginAllowed(origin string) bool
- func SetSessionCookie(w http.ResponseWriter, token string)
- type SessionAuth
- func (s *SessionAuth) CreateSession() (string, error)
- func (s *SessionAuth) DestroySession(token string)
- func (s *SessionAuth) IsEnabled() bool
- func (s *SessionAuth) RequireSession(next http.Handler) http.Handler
- func (s *SessionAuth) ValidatePassword(password string) bool
- func (s *SessionAuth) ValidateSession(token string) bool
Constants ¶
const (
SessionCookieName = "overwatch_session"
)
Variables ¶
This section is empty.
Functions ¶
func BearerAuth ¶
BearerAuth validates the Bearer token in the Authorization header
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
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