Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasPermission ¶
HasPermission checks if a user has a specific permission
Types ¶
type ChallengeStore ¶ added in v0.4.2
type ChallengeStore struct {
// contains filtered or unexported fields
}
ChallengeStore manages active authentication challenges
func NewChallengeStore ¶ added in v0.4.2
func NewChallengeStore() *ChallengeStore
NewChallengeStore creates a new challenge store
func (*ChallengeStore) GenerateChallenge ¶ added in v0.4.2
func (cs *ChallengeStore) GenerateChallenge() (*Challenge, error)
GenerateChallenge creates a new random challenge
func (*ChallengeStore) ValidateResponse ¶ added in v0.4.2
func (cs *ChallengeStore) ValidateResponse(nonce, response, token string) (bool, error)
ValidateResponse validates an HMAC response against a challenge
type Credential ¶
Credential represents an authentication credential (placeholder).
func (*Credential) Validate ¶
func (c *Credential) Validate() bool
Validate checks the credential (placeholder).
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware provides authentication middleware for HTTP handlers
func NewMiddleware ¶
func NewMiddleware(store *TokenStore) *Middleware
NewMiddleware creates a new auth middleware
func (*Middleware) HandleChallenge ¶ added in v0.4.2
func (m *Middleware) HandleChallenge(w http.ResponseWriter, r *http.Request)
HandleChallenge returns a new authentication challenge
func (*Middleware) OptionalAuth ¶
func (m *Middleware) OptionalAuth(next http.HandlerFunc) http.HandlerFunc
OptionalAuth wraps a handler to optionally accept authentication
func (*Middleware) RequireAuth ¶
func (m *Middleware) RequireAuth(requiredPermission string, next http.HandlerFunc) http.HandlerFunc
RequireAuth wraps a handler to require authentication Supports both Bearer token and Challenge-Response authentication
type Token ¶
type Token struct {
ID string `json:"id"`
TokenHash string `json:"token_hash"`
User string `json:"user"`
Permissions []string `json:"permissions"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
Revoked bool `json:"revoked"`
}
Token represents an authentication token
type TokenStore ¶
type TokenStore struct {
// contains filtered or unexported fields
}
TokenStore holds all tokens with thread-safe access
func NewTokenStore ¶
func NewTokenStore(filename string) (*TokenStore, error)
NewTokenStore creates a new token store
func (*TokenStore) GetTokenByID ¶ added in v0.4.2
func (ts *TokenStore) GetTokenByID(tokenID string) *Token
GetTokenByID retrieves a token by its ID (for challenge-response auth)
type TokenStoreFile ¶
type TokenStoreFile struct {
Tokens []Token `json:"tokens"`
}
TokenStoreFile represents the JSON file format