Documentation
¶
Overview ¶
Package auth provides authentication primitives for the DirIO admin console. It defines the AdminAuth interface (satisfied by an adapter in the server wiring) and the Session type for HMAC-signed, cookie-based login sessions.
Index ¶
- type AdminAuth
- type FlashData
- type Session
- func (s *Session) Clear(w http.ResponseWriter)
- func (s *Session) Create(w http.ResponseWriter, accessKey string) error
- func (s *Session) GetFlash(w http.ResponseWriter, r *http.Request) (FlashData, bool)
- func (s *Session) SetFlash(w http.ResponseWriter, message, msgType string)
- func (s *Session) Validate(r *http.Request) (accessKey string, ok bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminAuth ¶
type AdminAuth interface {
AuthenticateAdmin(ctx context.Context, accessKey, secretKey string) bool
}
AdminAuth validates that a given access-key/secret-key pair belongs to an admin user. The implementation lives in the server wiring layer and wraps internal/http/auth.Authenticator so this package stays free of internal/ imports.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session manages HMAC-SHA256 signed console session cookies. The signing key is randomly generated at startup, so sessions are invalidated when the server restarts — acceptable for an admin console.
func NewSession ¶
NewSession creates a Session with a randomly generated signing key.
func (*Session) Clear ¶
func (s *Session) Clear(w http.ResponseWriter)
Clear deletes the session cookie.
func (*Session) Create ¶
func (s *Session) Create(w http.ResponseWriter, accessKey string) error
Create writes a signed session cookie for the given access key.