Documentation
¶
Index ¶
- Constants
- func ClearSessionCookie(w http.ResponseWriter, secure bool)
- func HashPassword(password string) (string, error)
- func HashToken(token string) string
- func IsSecure(r *http.Request) bool
- func IssueCSRF(w http.ResponseWriter) string
- func SetSessionCookie(w http.ResponseWriter, opts SessionCookieOptions)
- func UserFromContext(ctx context.Context) *models.User
- func VerifyPassword(password, encoded string) bool
- func WithUser(ctx context.Context, u *models.User) context.Context
- type GeneratedSession
- type GeneratedToken
- type LoginRateLimiter
- type Middleware
- func (m *Middleware) AuthBearer(next http.Handler) http.Handler
- func (m *Middleware) AuthSession(next http.Handler) http.Handler
- func (m *Middleware) CSRF(next http.Handler) http.Handler
- func (m *Middleware) RequireUser(next http.Handler) http.Handler
- func (m *Middleware) VerifyPassword(u *models.User, current string) error
- type SessionCookieOptions
Constants ¶
View Source
const ( SessionCookie = "dodo_session" CSRFCookie = "dodo_csrf" SessionTTL = 30 * 24 * 60 * 60 )
Variables ¶
This section is empty.
Functions ¶
func ClearSessionCookie ¶
func ClearSessionCookie(w http.ResponseWriter, secure bool)
func HashPassword ¶
func IssueCSRF ¶
func IssueCSRF(w http.ResponseWriter) string
func SetSessionCookie ¶
func SetSessionCookie(w http.ResponseWriter, opts SessionCookieOptions)
func VerifyPassword ¶
Types ¶
type GeneratedSession ¶
func GenerateSession ¶
func GenerateSession() (GeneratedSession, error)
type GeneratedToken ¶
func GenerateAPIToken ¶
func GenerateAPIToken() (GeneratedToken, error)
type LoginRateLimiter ¶
type LoginRateLimiter struct {
// contains filtered or unexported fields
}
func NewLoginRateLimiter ¶
func NewLoginRateLimiter() *LoginRateLimiter
func (*LoginRateLimiter) Allow ¶
func (l *LoginRateLimiter) Allow(r *http.Request, email string) bool
func (*LoginRateLimiter) RecordFailure ¶
func (l *LoginRateLimiter) RecordFailure(r *http.Request, email string)
type Middleware ¶
func (*Middleware) AuthBearer ¶
func (m *Middleware) AuthBearer(next http.Handler) http.Handler
func (*Middleware) AuthSession ¶
func (m *Middleware) AuthSession(next http.Handler) http.Handler
func (*Middleware) RequireUser ¶
func (m *Middleware) RequireUser(next http.Handler) http.Handler
func (*Middleware) VerifyPassword ¶
func (m *Middleware) VerifyPassword(u *models.User, current string) error
Click to show internal directories.
Click to hide internal directories.