Documentation
¶
Overview ¶
Package standalone gives a Timeclock that runs on its own what a host would: accounts with a password, the workspaces each belongs to, sessions, invitations and password resets by email, optional sign-in with an OpenID Connect provider, and a directory of each workspace's people.
Index ¶
- Constants
- type Account
- type Auth
- func (a *Auth) Caller(r *http.Request) (string, bool)
- func (a *Auth) CreateWorkspace(ctx context.Context, svc *clock.Service, key, name string) error
- func (a *Auth) Invite(ctx context.Context, workspaceKey, email string, admin bool, ...) (Invited, error)
- func (a *Auth) People(ctx context.Context) ([]host.Person, error)
- func (a *Auth) Person(ctx context.Context, id string) (host.Person, error)
- func (a *Auth) Routes(mux *http.ServeMux)
- func (a *Auth) Workspace(r *http.Request) (string, bool)
- type Config
- type Invited
- type Membership
- type Passkey
- type SMTP
Constants ¶
const DevUserHeader = "X-Timeclock-Dev-User"
DevUserHeader names, in development only (Config.DevUser set), the email a request is signed in as instead of DevUser.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶ added in v0.4.0
type Account struct {
ID uuid.UUID `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
}
Account is someone who can sign in.
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth is a standalone Timeclock's accounts, sign-in and directory.
func New ¶
New sets up sign-in. In development it makes sure DevUser has an account; otherwise it invites each admin who has none yet.
func (*Auth) CreateWorkspace ¶ added in v0.4.0
CreateWorkspace makes a workspace, or renames one that exists.
func (*Auth) Invite ¶ added in v0.4.0
func (a *Auth) Invite(ctx context.Context, workspaceKey, email string, admin bool, invitedBy uuid.UUID) (Invited, error)
Invite invites an email address to a workspace and emails the link. invitedBy is the account that asked, or uuid.Nil for whoever runs the server.
type Config ¶
type Config struct {
// PublicURL is where people reach Timeclock: the links in its emails
// start with it, and an OpenID Connect provider redirects back to it.
PublicURL string
// Mailer sends invitations and password resets. Without one they go to
// the log, for whoever runs the server to pass on.
Mailer host.Mailer
// AdminEmails run payroll in every workspace they belong to, and are
// invited to the default workspace when the server first starts.
AdminEmails []string
// AuditorEmails read History, every change to payroll data, in every
// workspace they belong to. Being an admin doesn't make someone one.
AuditorEmails []string
// SecretKey seals what the server must read back but shouldn't sit in
// the database in the clear: authenticator secrets and providers' client
// secrets. At least 32 characters; keep it out of the database's backups.
SecretKey string
// TrustProxy says the server is behind a reverse proxy that sets
// X-Forwarded-For, so sign-in is slowed per client rather than for
// everyone behind the proxy at once. Leave it off when clients connect
// directly: they could claim any address.
TrustProxy bool
// BreachURL is the range API the breach check asks; empty is the public one.
BreachURL string
// BreachCheck refuses passwords found in a public list of breached
// ones. The lookup sends five characters of a hash, never the password.
BreachCheck bool
// Issuer, ClientID and ClientSecret are an OpenID Connect provider
// people can sign in with besides a password, such as
// https://accounts.google.com. Empty offers passwords only.
Issuer string
ClientID string
ClientSecret string
// AllowedDomain, if set, is the only email domain the provider may sign in.
AllowedDomain string
// DevUser, if set, is an email every request is signed in as, with no
// sign-in at all. For development only.
DevUser string
Logger *slog.Logger
}
Config configures Auth.
type Invited ¶ added in v0.4.0
type Invited struct {
ID uuid.UUID
Email string
// Link is where the person accepts it.
Link string
}
Invited is an invitation that was just made.
type Membership ¶ added in v0.4.0
type Membership struct {
ID uuid.UUID `json:"id"`
Key string `json:"key"`
Name string `json:"name"`
Admin bool `json:"admin"`
// SSORequired means it is entered only through its own provider.
SSORequired bool `json:"ssoRequired"`
}
Membership is a workspace an account belongs to.
type Passkey ¶ added in v0.4.0
type Passkey struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
LastUsedAt *time.Time `json:"lastUsedAt,omitempty"`
}
Passkey is a passkey as its owner sees it.
type SMTP ¶ added in v0.4.0
type SMTP struct {
// Host and Port are the server, such as "smtp.example.com" and "587".
Host, Port string
// Username and Password sign in, when the server asks for it.
Username, Password string
// From is the address mail comes from, such as "Timeclock <time@example.com>".
From string
// Security is "starttls" (the default), "tls" for a TLS connection from
// the start (port 465), or "none" for a server on a trusted network.
Security string
}
SMTP is how a standalone server sends email.