session

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken  = errors.New("invalid token")
	ErrExpiredToken  = errors.New("token expired")
	ErrTokenReplayed = errors.New("token already used")
)

Functions

func VerifyTokenGetSessionID

func VerifyTokenGetSessionID(signingKey []byte, token string) (string, error)

VerifyTokenGetSessionID verifies the HMAC signature and returns the session ID.

Types

type CertIssuanceMode added in v0.1.2

type CertIssuanceMode string

CertIssuanceMode controls how the portal treats certificate issuance for a session.

const (
	// CertIssuanceModeInPortal is the default. The portal offers an "Issue certificate" step
	// that pokes the internal cert manager and polls until a certificate is issued before the
	// user is sent back. This is also the effective mode when the field is empty, so existing
	// integrations keep the current behavior without opting in.
	CertIssuanceModeInPortal CertIssuanceMode = "in_portal"

	// CertIssuanceModeSkip tells the portal to declare success once ownership is verified and
	// the required DNS records validate. The certificate step is hidden and the user is sent
	// back immediately. Use this when the certificate is issued out-of-band (later, elsewhere,
	// or by an external system) and the portal only needs to confirm DNS setup.
	CertIssuanceModeSkip CertIssuanceMode = "skip"
)

type OwnershipVerificationMode

type OwnershipVerificationMode string

OwnershipVerificationMode controls what the portal shows the user for ownership verification.

const (
	// OwnershipVerificationModeDNSChallenge instructs the portal to show a DNS TXT record that
	// the user must add to prove ownership. When the user runs Setup Check, the portal performs
	// a live DNS lookup against _certmatic-verify.{hostname} and automatically sets
	// ownership_verified=true on the domain if the record matches.
	OwnershipVerificationModeDNSChallenge OwnershipVerificationMode = "dns_challenge"

	// OwnershipVerificationModeProviderManaged indicates that an external SaaS/provider controls
	// verification. The portal shows a configurable "Verify Ownership" button linking to the
	// provider dashboard. The provider (or admin) calls ownership_verified=true on the admin API.
	OwnershipVerificationModeProviderManaged OwnershipVerificationMode = "provider_managed"
)

type Session

type Session struct {
	SessionID                 string
	Hostname                  string
	ExpiresAt                 time.Time
	BackURL                   string
	BackText                  string
	OwnershipVerificationMode OwnershipVerificationMode
	VerifyOwnershipURL        string
	VerifyOwnershipText       string
	CertIssuanceMode          CertIssuanceMode
}

Session represents an authenticated portal session scoped to a single hostname.

func (*Session) EffectiveCertIssuanceMode added in v0.1.2

func (s *Session) EffectiveCertIssuanceMode() CertIssuanceMode

EffectiveCertIssuanceMode returns the mode to apply, treating the zero value as in_portal.

type SessionStore

type SessionStore interface {
	// StoreSession persists a newly created session.
	StoreSession(session *Session) error
	// RedeemToken validates an HMAC-signed token (one-time use) and returns the stored session.
	RedeemToken(signingKey []byte, token string) (*Session, error)
	// GetSession looks up an active session by session ID.
	GetSession(sessionID string) (*Session, error)
	// ClearExpired removes all sessions that have passed their expiry time.
	ClearExpired() error
}

SessionStore manages portal sessions.

Jump to

Keyboard shortcuts

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