Documentation
¶
Overview ¶
Package bootstrap gates creation of the first user behind a one-time setup token.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// SetupToken is the operator-supplied token. When empty a random one is
// generated at startup (if no user exists yet) and logged once.
SetupToken string
// OpenSignupAfterFirstUser reopens ordinary signup once the first user exists.
OpenSignupAfterFirstUser bool
// SuppressSetupTokenLog stops the generated token being logged; read it
// with TheAuth.SetupToken instead.
SuppressSetupTokenLog bool
// OnFirstUser runs after the first user is created, for example to
// grant the super admin role. Errors are logged and do not fail signup.
OnFirstUser func(ctx context.Context, user *models.User) error
}
Config closes public signup and gates creation of the first user behind a one-time setup token. The storage must implement UserCountStorage.
While no user exists, password signup requires the token in the X-Setup-Token header or a "setupToken" body field. After the first user exists, signup is refused with CodeSignupClosed unless OpenSignupAfterFirstUser is set. Magic-link account creation follows the same rule but can never present a token, so the first admin must sign up with a password. Granting the new user an admin role is left to OnFirstUser.