auth

package
v0.0.0-...-6a915cc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MFATypeWebAuthn = "MFATypeWebAuthn"
)

Variables

This section is empty.

Functions

func AdminOnlyMiddleware

func AdminOnlyMiddleware(h SessionHandler) echo.MiddlewareFunc

func AuthIsValid

func AuthIsValid(c echo.Context) bool

func CreateHeaderAuthMiddleware

func CreateHeaderAuthMiddleware() echo.MiddlewareFunc

func EnforceAuthMiddleware

func EnforceAuthMiddleware(args EnforceAuthArgs) echo.MiddlewareFunc

func EnforceMFAMiddleware

func EnforceMFAMiddleware(s SessionHandler) echo.MiddlewareFunc

func InitWebAuthn

func InitWebAuthn(baseURL url.URL)

func IsWebAuthnAvailable

func IsWebAuthnAvailable() bool

func MFAWebAuthnBeginLogin

func MFAWebAuthnBeginLogin(c echo.Context, sessHandler SessionHandler) (marshalledJSONResponse []byte, userPresentableErr error, internalErr error)

func MFAWebAuthnBeginRegister

func MFAWebAuthnBeginRegister(c echo.Context, sessHandler SessionHandler) (marshalledJSONResponse []byte, userPresentableErr error, internalErr error)

func MFAWebAuthnFinishLogin

func MFAWebAuthnFinishLogin(c echo.Context, sessHandler SessionHandler) (userPresentableErr error, internalErr error)

func MFAWebAuthnFinishRegister

func MFAWebAuthnFinishRegister(c echo.Context, sessHandler SessionHandler) (userPresentableErr error, internalErr error)

func RoleRestrictedMiddleware

func RoleRestrictedMiddleware(allowedRoles []string, disallowedRoles []string) echo.MiddlewareFunc

func UserFromReq

func UserFromReq(c echo.Context) *db.User

Types

type EnforceAuthArgs

type EnforceAuthArgs struct {
	BypassPaths []string
}

type InMemorySessionHandler

type InMemorySessionHandler struct {
	CookieName         string
	SessionTimeout     time.Duration
	SessionMaxLifetime time.Duration
	// contains filtered or unexported fields
}

func (*InMemorySessionHandler) CreateMiddleware

func (s *InMemorySessionHandler) CreateMiddleware() echo.MiddlewareFunc

func (*InMemorySessionHandler) Destroy

func (s *InMemorySessionHandler) Destroy(c echo.Context) error

func (*InMemorySessionHandler) LogoutAllSessionsForUser

func (s *InMemorySessionHandler) LogoutAllSessionsForUser(userId string) error

func (*InMemorySessionHandler) Refresh

func (s *InMemorySessionHandler) Refresh(c echo.Context) error

func (*InMemorySessionHandler) Rotate

func (s *InMemorySessionHandler) Rotate(c echo.Context) error

func (*InMemorySessionHandler) Start

func (s *InMemorySessionHandler) Start(c echo.Context, sess SessionData) error

func (*InMemorySessionHandler) UpdateSessionData

func (s *InMemorySessionHandler) UpdateSessionData(c echo.Context, updateFunc func(*SessionData) error) error

type SessionData

type SessionData struct {
	UserID          string
	HasCompletedMFA bool

	WebAuthnSession     *webauthn.SessionData
	PendingWebAuthnUser *webauthnUser
}

func SessionDataFromReq

func SessionDataFromReq(c echo.Context) *SessionData

func UserAndSessFromReq

func UserAndSessFromReq(c echo.Context) (*db.User, *SessionData)

type SessionHandler

type SessionHandler interface {
	CreateMiddleware() echo.MiddlewareFunc

	Start(echo.Context, SessionData) error
	Destroy(echo.Context) error
	Refresh(echo.Context) error
	Rotate(echo.Context) error // Rotate session cookie, to mitigate session fixation
	UpdateSessionData(c echo.Context, updateFunc func(*SessionData) error) error

	LogoutAllSessionsForUser(id string) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL