Documentation
¶
Index ¶
- Constants
- Variables
- func User[T any](r *AuthenticationFilter[T], request *web.Request) (T, error)
- func WithLogin() web.MetaOption
- type Authentication
- type AuthenticationFilter
- func (s *AuthenticationFilter[U]) Handle(filterChain web.FilterChain, request *web.Request) (any, error)
- func (s *AuthenticationFilter[U]) Init(ctx *core.Context) error
- func (s *AuthenticationFilter[U]) SignIn(user any, request *web.Request) (any, error)
- func (s *AuthenticationFilter[U]) SignOut(request *web.Request) (any, error)
- func (s *AuthenticationFilter[U]) User(request *web.Request) (U, error)
Constants ¶
View Source
const (
LoginKey = "login"
)
Variables ¶
View Source
var NoLogin = web.NewForbidden().WithDetail("Not logged in")
NoLogin is the sentinel error returned when a user is not authenticated.
Functions ¶
func User ¶
func User[T any](r *AuthenticationFilter[T], request *web.Request) (T, error)
User retrieves the authenticated user from the filter, cast to type T.
func WithLogin ¶
func WithLogin() web.MetaOption
WithLogin returns a MetaOption that marks a route as requiring authentication.
Types ¶
type Authentication ¶
type Authentication[U any] interface { core.IService SignIn(value any, request *web.Request) (any, error) SignOut(request *web.Request) (any, error) User(request *web.Request) (U, error) }
Authentication defines the interface for authentication services.
type AuthenticationFilter ¶
type AuthenticationFilter[U any] struct { // contains filtered or unexported fields }
AuthenticationFilter is a filter that enforces authentication on protected routes.
func NewAuthenticationFilter ¶
func NewAuthenticationFilter[T any](authentication Authentication[T]) *AuthenticationFilter[T]
NewAuthenticationFilter creates a new authentication filter with the given provider.
func (*AuthenticationFilter[U]) Handle ¶
func (s *AuthenticationFilter[U]) Handle(filterChain web.FilterChain, request *web.Request) (any, error)
func (*AuthenticationFilter[U]) Init ¶
func (s *AuthenticationFilter[U]) Init(ctx *core.Context) error
Click to show internal directories.
Click to hide internal directories.