auth

package
v3.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package auth provides infrastructure implementations for authentication services defined in pericarp's auth application layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProvideInviteTokenService

func ProvideInviteTokenService(cfg config.Config) (application.InviteTokenService, error)

ProvideInviteTokenService is the Fx provider that wires an HMACInviteTokenService using the configured SESSION_SECRET.

Types

type HMACInviteTokenService

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

HMACInviteTokenService implements pericarp's application.InviteTokenService using HMAC-SHA256 signed JWTs. It reuses the existing session secret so WeOS deployments can issue invite tokens without any new infrastructure.

func NewHMACInviteTokenService

func NewHMACInviteTokenService(secret string) (*HMACInviteTokenService, error)

NewHMACInviteTokenService creates a new HMAC-SHA256 invite token service from the given secret. The secret must be non-empty.

func (*HMACInviteTokenService) IssueInviteToken

func (s *HMACInviteTokenService) IssueInviteToken(
	ctx context.Context, inviteID string, expiry time.Duration,
) (string, error)

IssueInviteToken creates an HMAC-SHA256 signed JWT for the given invite. The token's subject and custom invite_id claim are both set to inviteID, and it expires after the given duration.

func (*HMACInviteTokenService) ValidateInviteToken

func (s *HMACInviteTokenService) ValidateInviteToken(
	ctx context.Context, tokenString string,
) (*application.InviteClaims, error)

ValidateInviteToken parses and validates an HMAC-SHA256 signed invite token, returning the claims. Expired tokens return application.ErrTokenExpired and all other parse/signature failures return application.ErrTokenInvalid.

Jump to

Keyboard shortcuts

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