auth

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package auth issues and verifies generic lobby guest credentials. It performs no environment reads, database setup, or HTTP registration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PlayerTokens

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

PlayerTokens issues the player tokens that games verify with the lobby's public keys, and publishes those keys.

func NewPlayerTokens

func NewPlayerTokens(keys *playertoken.KeySet, issuer string, lifetime time.Duration, clock domain.Clock, policy domain.Policy) (*PlayerTokens, error)

NewPlayerTokens signs with keys as issuer, the lobby's public URL, for the games of policy. A token lasts lifetime, at most playertoken.MaxLifetime, and never past its session.

func (*PlayerTokens) IssuePlayerToken

func (tokens *PlayerTokens) IssuePlayerToken(ctx context.Context, verification domain.SessionVerification, gameKey string) (domain.PlayerToken, error)

IssuePlayerToken signs a token for the session's player and gameKey. The token expires after the lifetime or with the session, whichever comes first. An unknown game is ErrNotFound.

func (*PlayerTokens) PublicKeys

func (tokens *PlayerTokens) PublicKeys() playertoken.JWKS

PublicKeys is the JWKS of every key: the one that signs, and any previous ones.

type Service

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

Service implements both the Authenticator and ConnectionTokenIssuer ports. Its dependencies are injected so bootstrap selects secrets and production I/O.

func NewService

func NewService(
	identities domain.IdentityStore,
	clock domain.Clock,
	policy domain.Policy,
	identifiers domain.IdentifierSource,
	signingSecret []byte,
	publicWebsocketURL string,
) (*Service, error)

NewService validates all configuration required for guest credentials and Centrifugo connection JWTs. The secret is copied before retaining it.

func (*Service) Authenticate

func (service *Service) Authenticate(ctx context.Context, authorization string) (domain.SessionVerification, error)

func (*Service) CreateGuest

func (service *Service) CreateGuest(ctx context.Context, request domain.CreateGuestRequest) (domain.GuestSession, error)

func (*Service) IssueConnectionToken

func (service *Service) IssueConnectionToken(ctx context.Context, verification domain.SessionVerification) (domain.ConnectionToken, error)

IssueConnectionToken rechecks the durable one-session identity before signing a short connection JWT. This prevents an arbitrary constructed verification value from becoming authority and creates no lobby-side state.

Jump to

Keyboard shortcuts

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