Help us shape the future of Go! Take the 2026 Go Developer Survey

admin

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MinPasswordLen = 8

MinPasswordLen is the minimum accepted password length, enforced at every entry point (CLI, HTTP form, GOLEM_ADMIN_PASSWORD env var).

Variables

View Source
var ErrLastAdmin = errors.New("refusing to leave the orchestrator with no admin user")

ErrLastAdmin is returned when an operation would leave the orchestrator with no admin user.

View Source
var ErrUnknownRole = errors.New("unknown role")

ErrUnknownRole is returned when a role string is not a known rbac role.

View Source
var ErrWeakPassword = errors.New("password too weak")

ErrWeakPassword is returned when a password fails ValidatePassword.

View Source
var ErrWrongPassword = errors.New("current password is incorrect")

ErrWrongPassword is returned when a change-password call presents an old password that does not match the stored hash.

Functions

func ChangePassword added in v0.0.3

func ChangePassword(gdb *gorm.DB, userID uint, oldPass, newPass string) error

ChangePassword replaces the given user's password hash after verifying the old password. Sessions are not revoked so the caller stays signed in on the device they used to change it; a separate "sign out everywhere" is a future feature. Returns ErrWrongPassword if oldPass does not match, or ErrWeakPassword if newPass fails ValidatePassword.

func ShemsAdd

func ShemsAdd(gdb *gorm.DB, name string) error

ShemsAdd generates a random 32-byte hex API key, stores its bcrypt hash, and prints the raw key once to stdout.

func ShemsAddOrUpdate

func ShemsAddOrUpdate(gdb *gorm.DB, name, key string) error

ShemsAddOrUpdate creates a shem with the given name and API key, or updates its key hash if the shem already exists. Used for env-var-based auto-setup.

func ShemsRemove

func ShemsRemove(gdb *gorm.DB, name string) error

ShemsRemove hard-deletes the shem with the given name.

func UsersAdd

func UsersAdd(gdb *gorm.DB, username, role string) error

UsersAdd prompts for a password (or reads GOLEM_ADMIN_PASSWORD), bcrypt-hashes it, and inserts a new User with the given role. The env var allows non-interactive use in Docker.

func UsersAddOrUpdate

func UsersAddOrUpdate(gdb *gorm.DB, username, password, role string) error

UsersAddOrUpdate creates a user with the given username, password and role, or updates the password hash and role if the user already exists.

func UsersList added in v0.0.3

func UsersList(gdb *gorm.DB) ([]db.User, error)

UsersList returns all users ordered by username.

func UsersRemove

func UsersRemove(gdb *gorm.DB, username string) error

UsersRemove hard-deletes the user with the given username along with all their sessions, so their access is revoked immediately. It refuses to remove the last admin, and reports an error if the user does not exist.

func UsersSetRole added in v0.0.3

func UsersSetRole(gdb *gorm.DB, username, role string) error

UsersSetRole changes a user's role, refusing to demote the last admin.

func ValidatePassword added in v0.0.3

func ValidatePassword(pass string) error

ValidatePassword returns ErrWeakPassword if pass is unacceptable. Keep this the single source of truth so the UI, CLI, and env-var seed can't drift.

Types

This section is empty.

Jump to

Keyboard shortcuts

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