Documentation
¶
Overview ¶
Package extaccountapi is the REST surface of external accounts (#2092): the admin routes that create, list, extend, suspend, resume and remove the accounts and edit their settings, and the two public routes a person signs in through, asking for a link and claiming it.
Index ¶
Constants ¶
const (
// RequestPath is the public route a sign-in link is asked for on.
RequestPath = "/portal/auth/email-link"
)
Variables ¶
This section is empty.
Functions ¶
func RegisterAdmin ¶
RegisterAdmin mounts the admin routes behind wrap, the admin API's authentication.
func RegisterPublic ¶
RegisterPublic mounts the routes a person signs in through. They take no authentication: asking for a link answers the same for every address, and a link is its own credential.
Types ¶
type Config ¶
type Config struct {
Service Service
Settings SettingsStore
SharedItems func(ctx context.Context, email string) (int, error)
// Author resolves the acting admin.
Author func(*http.Request) string
// Now is the clock; nil is time.Now.
Now func() time.Time
}
Config is what the routes are built from.
type ExtendRequest ¶
type ExtendRequest struct {
// ExpiresAt is the new expiry; null removes it.
ExpiresAt *time.Time `json:"expires_at"`
}
ExtendRequest sets or clears an account's expiry.
type LinkRequest ¶
type LinkRequest struct {
Email string `json:"email" example:"client@example.org"`
}
LinkRequest asks for a sign-in link.
type Service ¶
type Service interface {
Create(ctx context.Context, n extaccount.NewAccount, by string) (extaccount.Account, error)
List(ctx context.Context) ([]extaccount.Account, error)
Extend(ctx context.Context, id string, expiresAt *time.Time) error
Suspend(ctx context.Context, id string) error
Resume(ctx context.Context, id string) error
Remove(ctx context.Context, id string) error
RequestLink(ctx context.Context, email string)
Claim(ctx context.Context, w http.ResponseWriter, token string) (extaccount.Account, error)
}
Service is the account service the routes call.
type SettingsStore ¶
type SettingsStore interface {
Read(ctx context.Context) extaccount.Settings
Write(ctx context.Context, s extaccount.Settings, author string) error
}
SettingsStore reads and writes the settings section.