ubwww

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthTokenCookie

type AuthTokenCookie interface {
	ToUserIdentity() UserIdentity
	IsExpired() bool
	Touch(unixSec int64)
}

type AuthTokenCookieManager

type AuthTokenCookieManager[T AuthTokenCookie] interface {
	ClearAuthTokenCookie(w http.ResponseWriter)
	ReadAuthTokenCookie(r *http.Request) (bool, T, error)
	WriteAuthTokenCookie(w http.ResponseWriter, token T) error
	Middleware(handler http.Handler) http.Handler
	MiddlewareFunc(handler http.HandlerFunc) http.HandlerFunc
	TokenFromContext(ctx context.Context) (T, bool)
	IdentityFromContext(ctx context.Context) (UserIdentity, bool)
}

func NewCookieMonster

func NewCookieMonster[T AuthTokenCookie](
	encryptionService ubsecurity.EncryptionService,
	cookieName string,
	secure bool,
	tokenSoftExpiry int64,
	cookieKey CookieContextKey,
	identityKey IdentityContextKey) AuthTokenCookieManager[T]

type CookieContextKey

type CookieContextKey string

type CookieMonster

type CookieMonster[T AuthTokenCookie] struct {
	// contains filtered or unexported fields
}

func (*CookieMonster[T]) ClearAuthTokenCookie

func (c *CookieMonster[T]) ClearAuthTokenCookie(w http.ResponseWriter)

func (*CookieMonster[T]) IdentityFromContext added in v0.0.21

func (c *CookieMonster[T]) IdentityFromContext(ctx context.Context) (UserIdentity, bool)

func (*CookieMonster[T]) Middleware

func (c *CookieMonster[T]) Middleware(handler http.Handler) http.Handler

func (*CookieMonster[T]) MiddlewareFunc

func (c *CookieMonster[T]) MiddlewareFunc(handler http.HandlerFunc) http.HandlerFunc

func (*CookieMonster[T]) ReadAuthTokenCookie

func (c *CookieMonster[T]) ReadAuthTokenCookie(r *http.Request) (bool, T, error)

func (*CookieMonster[T]) TokenFromContext added in v0.0.21

func (c *CookieMonster[T]) TokenFromContext(ctx context.Context) (T, bool)

func (*CookieMonster[T]) WriteAuthTokenCookie

func (c *CookieMonster[T]) WriteAuthTokenCookie(w http.ResponseWriter, token T) error

type IdentityContextKey added in v0.0.21

type IdentityContextKey string

type UserIdentity added in v0.0.21

type UserIdentity struct {
	UserID         int64
	Email          string
	OrganizationID int64
}

func (*UserIdentity) ToAgent added in v0.0.21

func (u *UserIdentity) ToAgent() string

Jump to

Keyboard shortcuts

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