Documentation
¶
Overview ¶
Package bootstrapmeta holds shared constants and helpers for system DB first-run bootstrap. Orchestration lives in each ApitoSystemDB driver implementation.
Index ¶
- Constants
- func BootstrapAdminEmail() string
- func ExistingStarterProjectID(ctx context.Context, ...) string
- func HashBootstrapAdminSecret() (hash []byte, plain string, err error)
- func HashDefaultAdminPassword() ([]byte, error)
- func IsUserLookupMiss(err error) bool
- func LogDefaultAdminCredentials(email, plainPassword string)
- func NewBootstrapAdminUser(id, username, now, passwordHash string) *models.SystemUser
- func RepairSuperAdminEmails(ctx context.Context, getByEmail SuperAdminGetter, update SuperAdminUpdater) error
- func ResolveBootstrapAdminPassword() (plain string, generated bool)
- func SuperAdminEmails() []string
- type CreateStarterProjectFn
- type SuperAdminGetter
- type SuperAdminUpdater
Constants ¶
const ( AdminEmail = "admin@apito.io" DefaultAdminPass = "#ApitoRocks#" AdminFirstName = "Apito" AdminLastName = "Admin" StarterProjectID = "todo_notes" StarterProjectName = "Apito Website" // PreviousStarterProjectID is the starter id used before Todo Notes. // A system database that already has this project keeps it. PreviousStarterProjectID = "apito_website" // OSSStarterSQLiteFile is the SQLite filename (under Config.DefaultDatabaseDir) for the bundled // starter project when SYSTEM_DB_ENGINE=coredb. Not read from PROJECT_DB_* env. OSSStarterSQLiteFile = "apito_starter.sqlite" // StarterMongoDatabaseName is the logical Mongo database for the OSS starter project when the // system database is MongoDB (uses SYSTEM_DB_* connection fields). StarterMongoDatabaseName = "apito_starter_todo_notes" // StarterPostgresDatabaseName is the physical database for the OSS starter project when the // system database engine is PostgreSQL (uses SYSTEM_DB_* connection as admin; InitProjectBase creates the DB). StarterPostgresDatabaseName = "apito_starter_todo_notes" )
Variables ¶
This section is empty.
Functions ¶
func BootstrapAdminEmail ¶
func BootstrapAdminEmail() string
BootstrapAdminEmail is the first-run operator email. BOOTSTRAP_ADMIN_EMAIL overrides; default is AdminEmail (admin@apito.io).
func ExistingStarterProjectID ¶
func ExistingStarterProjectID(ctx context.Context, get func(context.Context, string) (*models.Project, error)) string
ExistingStarterProjectID returns the starter row this system database should keep using. A database that already contains the previous starter id does not gain a second project.
func HashBootstrapAdminSecret ¶
HashBootstrapAdminSecret bcrypt-hashes ResolveBootstrapAdminPassword.
func HashDefaultAdminPassword ¶
HashDefaultAdminPassword returns a bcrypt hash for the default bootstrap password.
func IsUserLookupMiss ¶
IsUserLookupMiss reports whether err means the user document was not found.
func LogDefaultAdminCredentials ¶
func LogDefaultAdminCredentials(email, plainPassword string)
LogDefaultAdminCredentials prints the bordered login banner (plaintext password).
func NewBootstrapAdminUser ¶
func NewBootstrapAdminUser(id, username, now, passwordHash string) *models.SystemUser
NewBootstrapAdminUser builds the first-run operator row with the platform flag.
func RepairSuperAdminEmails ¶
func RepairSuperAdminEmails(ctx context.Context, getByEmail SuperAdminGetter, update SuperAdminUpdater) error
RepairSuperAdminEmails sets is_super_admin=true on existing rows whose email is in SuperAdminEmails. Missing emails are skipped (no auto-create except bootstrap admin).
func ResolveBootstrapAdminPassword ¶
ResolveBootstrapAdminPassword returns the plaintext used only on first create. BOOTSTRAP_ADMIN_PASSWORD wins. Else BOOTSTRAP_ADMIN_RANDOM_PASSWORD=true generates a one-shot secret (logged once). Else DefaultAdminPass (local/tests).
func SuperAdminEmails ¶
func SuperAdminEmails() []string
SuperAdminEmails returns the platform-operator email list. Default is BootstrapAdminEmail(). SUPER_ADMIN_EMAILS is a comma-separated extra list.
Types ¶
type CreateStarterProjectFn ¶
CreateStarterProjectFn creates the starter project row when it does not exist yet.
type SuperAdminGetter ¶
SuperAdminGetter loads a system user by email.
type SuperAdminUpdater ¶
SuperAdminUpdater persists a system user row.