auth

package
v0.0.0-...-4f695cd Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClaimsContextKey contextKey = "claims"

	// Permissions
	CreateURLs    permission = "create:urls"
	DeleteURLs    permission = "delete:urls"
	DeleteOwnURLs permission = "delete:own-urls"
	GetOwnURLs    permission = "get:own-urls"
	GetURL        permission = "get:url"
	GetURLs       permission = "get:urls"
	UserBlock     permission = "user:block"
	UserUnblock   permission = "user:unblock"
	GetUserBlocks permission = "get:user-blocks"
)

Variables

This section is empty.

Functions

func GetUserID

func GetUserID(c *echo.Context) *string

Types

type CustomClaims

type CustomClaims struct {
	Scope       string   `json:"scope"`
	Permissions []string `json:"permissions"`
}

CustomClaims contains custom data we want from the token

func (CustomClaims) HasPermission

func (c CustomClaims) HasPermission(expectedPermission permission) bool

HasPermission checks whether claims have a specific permission

func (CustomClaims) HasScope

func (c CustomClaims) HasScope(expectedScope string) bool

HasScope checks whether claims have a specific scope

func (CustomClaims) Validate

func (c CustomClaims) Validate(ctx context.Context) error

Validate does nothing, but we need it to satisfy validator.CustomClaims interface

type Management

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

func NewManagement

func NewManagement(logger *slog.Logger, cfg config.Auth) *Management

func (*Management) BlockUser

func (*Management) UnblockUser

func (m *Management) UnblockUser(ctx context.Context, userID string) error

type Middleware

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

func NewMiddleware

func NewMiddleware(cfg config.Auth) *Middleware

func (*Middleware) Authenticate

func (m *Middleware) Authenticate(next echo.HandlerFunc) echo.HandlerFunc

Authenticate is a middleware that will check the validity of the JWT if it is present

func (*Middleware) RequireAuthentication

func (m *Middleware) RequireAuthentication(next echo.HandlerFunc) echo.HandlerFunc

func (*Middleware) RequirePermission

func (m *Middleware) RequirePermission(permission permission) echo.MiddlewareFunc

Jump to

Keyboard shortcuts

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