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.