auth

package module
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

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

func (*AuthenticationFilter[U]) SignIn

func (s *AuthenticationFilter[U]) SignIn(user any, request *web.Request) (any, error)

func (*AuthenticationFilter[U]) SignOut

func (s *AuthenticationFilter[U]) SignOut(request *web.Request) (any, error)

func (*AuthenticationFilter[U]) User

func (s *AuthenticationFilter[U]) User(request *web.Request) (U, error)

Jump to

Keyboard shortcuts

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