bootstrapmeta

package
v0.0.0-...-ec2e5f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package bootstrapmeta holds shared constants and helpers for system DB first-run bootstrap. Orchestration lives in each ApitoSystemDB driver implementation.

Index

Constants

View Source
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

func HashBootstrapAdminSecret() (hash []byte, plain string, err error)

HashBootstrapAdminSecret bcrypt-hashes ResolveBootstrapAdminPassword.

func HashDefaultAdminPassword

func HashDefaultAdminPassword() ([]byte, error)

HashDefaultAdminPassword returns a bcrypt hash for the default bootstrap password.

func IsUserLookupMiss

func IsUserLookupMiss(err error) bool

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

func ResolveBootstrapAdminPassword() (plain string, generated bool)

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

type CreateStarterProjectFn func(ctx context.Context, userID string, proj *models.Project) error

CreateStarterProjectFn creates the starter project row when it does not exist yet.

type SuperAdminGetter

type SuperAdminGetter func(ctx context.Context, email string) (*models.SystemUser, error)

SuperAdminGetter loads a system user by email.

type SuperAdminUpdater

type SuperAdminUpdater func(ctx context.Context, user *models.SystemUser, replace bool) error

SuperAdminUpdater persists a system user row.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL