Documentation
¶
Overview ¶
Package auth implements single-user session authentication using a signed cookie. The move to multi-user later replaces the credential check and the uid baked into the cookie; the cookie mechanism stays the same.
Index ¶
- type Manager
- func (m *Manager) APIAuthed(r *http.Request) bool
- func (m *Manager) Authed(r *http.Request) bool
- func (m *Manager) Check(user, pass string) bool
- func (m *Manager) Clear(w http.ResponseWriter)
- func (m *Manager) Require(next http.Handler) http.Handler
- func (m *Manager) SetSession(w http.ResponseWriter, uid uint)
- func (m *Manager) WithDB(db *gorm.DB) *Manager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager issues and validates session cookies, and authenticates API tokens.
func (*Manager) APIAuthed ¶
APIAuthed reports whether the request is authenticated by either a valid session cookie or a valid API bearer token.
func (*Manager) Clear ¶
func (m *Manager) Clear(w http.ResponseWriter)
Clear removes the session cookie (logout).
func (*Manager) Require ¶
Require is middleware that 401s API requests lacking a valid session cookie or API bearer token.
func (*Manager) SetSession ¶
func (m *Manager) SetSession(w http.ResponseWriter, uid uint)
SetSession writes the session cookie after a successful login.
Click to show internal directories.
Click to hide internal directories.