authn

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(role, secret string, expiry ...time.Duration) (string, error)

GenerateToken creates a signed JWT for the given role. If expiry > 0, the token will include exp and iat claims. If expiry == 0, the token has no expiration (for testing or long-lived tokens).

func Middleware

func Middleware(cfg MiddlewareConfig, forceDBE bool, getDBName GetDatabaseNameFn) heligo.Middleware

Types

type Claims

type Claims struct {
	Role string `json:"role"`
	Id   string `json:"id"`
	jwt.RegisteredClaims
	RawClaims string `json:"-"`
}

func (*Claims) UnmarshalJSON added in v0.2.11

func (c *Claims) UnmarshalJSON(data []byte) error

type GetDatabaseNameFn

type GetDatabaseNameFn func(ctx context.Context, r heligo.Request) string

type MiddlewareConfig

type MiddlewareConfig interface {
	GetDatabase(context.Context, string) (*database.Database, error)
	JWTSecret() string
	AllowAnon() bool
	AnonRole() string
	RequestMaxBytes() int64
	SessionManager() *SessionManager
	GetLogger() *logging.Logger
}

type Session

type Session struct {
	Claims     *Claims
	LastUsedAt time.Time
	Db         *database.Database
	DbConn     *database.DbPoolConn
	// contains filtered or unexported fields
}

A Session for SmoothDB is the way to cache information about a user and his connection to a database

type SessionList

type SessionList struct {
	// contains filtered or unexported fields
}

type SessionManager

type SessionManager struct {
	// contains filtered or unexported fields
}

SessionManager manages user sessions and monitors them efficiently. When disabled, it simply returns Sessions without managing or monitoring.

func NewSessionManager

func NewSessionManager(logger *logging.Logger, enabled bool, shutdown chan struct{}) *SessionManager

func (*SessionManager) Statistics

func (sm *SessionManager) Statistics() SessionStatistics

type SessionStatistics

type SessionStatistics struct {
	Count int
	InUse int
	Users int
}

Jump to

Keyboard shortcuts

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