auth

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const TenantIDContextKey = "auth.tenant_id"

Variables

This section is empty.

Functions

func GenerateTenantToken

func GenerateTenantToken(secret, issuer, tenantID string, ttl time.Duration) (string, error)

func Middleware

func Middleware(a Authenticator) gin.HandlerFunc

func TenantIDFromGin

func TenantIDFromGin(c *gin.Context) (string, bool)

Types

type Authenticator

type Authenticator interface {
	Authenticate(ctx context.Context, token string) (tenantID string, err error)
}

type JWTAuthenticator

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

func NewJWTAuthenticator

func NewJWTAuthenticator(secret, issuer string) (*JWTAuthenticator, error)

func (*JWTAuthenticator) Authenticate

func (a *JWTAuthenticator) Authenticate(ctx context.Context, token string) (string, error)

type TenantClaims

type TenantClaims struct {
	TenantID string `json:"tenant_id"`
	jwt.RegisteredClaims
}

Jump to

Keyboard shortcuts

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