Documentation
¶
Overview ¶
Package signupgate keeps platform sign-up invites and implements the systemauth.SignupGate that enforces them. With the gate installed a deployment creates accounts only for verified emails that hold an invite; people who already have an account sign in as before.
An invite is an email address, not a code: the person proves control of the address by signing in through the upstream provider, and the gate compares that verified address with the invites. Nothing is sent and nothing needs to be typed.
Index ¶
- Variables
- func NormalizeEmail(raw string) (string, error)
- func WriteWaitlistCSV(out io.Writer, entries []WaitlistEntry) error
- type AddOptions
- type Gate
- type Invite
- type Store
- func (s *Store) Add(ctx context.Context, email string, opts AddOptions) (*Invite, error)
- func (s *Store) Allowed(ctx context.Context, email string) (bool, error)
- func (s *Store) List(ctx context.Context, includeRedeemed bool) ([]Invite, error)
- func (s *Store) Redeem(ctx context.Context, email string, principalID uuid.UUID) error
- func (s *Store) Revoke(ctx context.Context, email string) error
- type Waitlist
- type WaitlistEntry
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidEmail means the address is not a plain email address. ErrInvalidEmail = errors.New("signupgate: not a plain email address") // ErrAlreadyRedeemed means an account was already created with the // invite. Revoke it to invite the address again. ErrAlreadyRedeemed = errors.New("signupgate: invite already redeemed") // ErrNotFound means no invite exists for the address. ErrNotFound = errors.New("signupgate: no invite for that address") )
Functions ¶
func NormalizeEmail ¶
NormalizeEmail returns the stored form of an address: trimmed and lower-case. A display name, a comment or a missing domain is refused.
func WriteWaitlistCSV ¶
func WriteWaitlistCSV(out io.Writer, entries []WaitlistEntry) error
WriteWaitlistCSV writes entries as CSV with a header row: email, joined and last submitted times (RFC 3339, UTC) and the consent version.
Types ¶
type AddOptions ¶
type AddOptions struct {
// Note is free-text context for operators.
Note string
// InvitedBy labels the operator creating the invite.
InvitedBy string
// ExpiresAt ends the invite; nil means it does not expire.
ExpiresAt *time.Time
}
AddOptions are the optional parts of a new invite.
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
Gate is the systemauth.SignupGate over a Store.
func NewGate ¶
NewGate returns a gate that allows a sign-up when the login's verified email holds a pending invite.
func (*Gate) AllowSignup ¶
func (g *Gate) AllowSignup(ctx context.Context, login systemauth.ExternalLogin) error
AllowSignup implements systemauth.SignupGate. Only a verified email can match: an unverified address is never trusted, and the directory refuses to create an account for one anyway.
func (*Gate) SignedUp ¶
func (g *Gate) SignedUp(ctx context.Context, login systemauth.ExternalLogin, principalID uuid.UUID) error
SignedUp implements systemauth.SignupGate by consuming the invite.
type Invite ¶
type Invite struct {
Email string
Note string
InvitedBy string
CreatedAt time.Time
ExpiresAt *time.Time
RedeemedAt *time.Time
RedeemedBy *uuid.UUID
}
Invite is a sign-up invite as listed to operators.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store reads and writes invites.
func (*Store) Add ¶
Add creates an invite, or updates the note, label and expiry of a pending one. It returns ErrAlreadyRedeemed for an address that already has an account created through its invite.
func (*Store) Allowed ¶
Allowed reports whether the address holds an invite that is neither redeemed nor expired.
func (*Store) List ¶
List returns invites ordered by address. Redeemed invites are included only when includeRedeemed is set.
func (*Store) Redeem ¶
Redeem marks the invite for an address as used by the principal. It does nothing, and reports no error, when the invite was already used, so a repeated call is harmless.
type Waitlist ¶
type Waitlist struct {
// contains filtered or unexported fields
}
Waitlist stores the addresses that asked to be notified while a deployment is invite-only. It sends nothing itself: operators export it.
func NewWaitlist ¶
NewWaitlist returns a Waitlist over client.
func (*Waitlist) Join ¶
Join adds an address, or refreshes the consent recorded for one already listed. Either way the caller learns nothing about whether it was listed before, so a public form built on it cannot be used to probe addresses.
type WaitlistEntry ¶
type WaitlistEntry struct {
Email string
ConsentVersion string
ConsentText string
// CreatedAt is when the address first joined; UpdatedAt when it was
// last submitted.
CreatedAt time.Time
UpdatedAt time.Time
}
WaitlistEntry is an address waiting to be told that sign-up is open.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package signupcmd provides the operator commands for invite-only sign-up as cobra commands a host CLI mounts: "invite" (add, list, revoke) and "waitlist" (list, remove).
|
Package signupcmd provides the operator commands for invite-only sign-up as cobra commands a host CLI mounts: "invite" (add, list, revoke) and "waitlist" (list, remove). |