Documentation
¶
Overview ¶
Package core defines the bootstrapped core application for identity, roles, and permissions.
Index ¶
Constants ¶
const ( AdminEmail = "admin@localhost" AdminRole = "System Administrator" )
Variables ¶
var App = app.Definition{ Name: "core", Title: "Orjanda Core", Version: "0.1.0", Description: "Core identity, role, and permission documents", Publisher: "Orjanda Framework", Modules: []app.Module{ {Name: "core", Title: "Core"}, }, }
App is the app.Definition for Orjanda Core. See PRD §11 and TAD §4.
Functions ¶
func Bootstrap ¶
Bootstrap executes the first-run system administrator setup if no users exist. Returns (password, nil) if bootstrapped, or ("", nil) if already bootstrapped. Idempotent: does nothing on subsequent calls. The whole sequence runs inside a single transaction (REVIEW-2026-08-12 finding 12): the User-empty check and every insert share one write transaction, and the database enforces uniqueness on User.email / Role.role_name, so concurrent serve instances can never create duplicate admins. See TAD §4.2.
func RegisterUserHooks ¶
RegisterUserHooks installs the core User lifecycle hooks. The stored Password value is a bcrypt hash (TAD §4.1, PRD §15.1): a plaintext password written through the Document Engine is hashed on before_save so the built-in login endpoint (api/auth.go) can verify it. Values that are already bcrypt hashes pass through untouched, so updates that re-send a stored hash are idempotent.
Call once per site with the site's EventBus. The hook is keyed by the docType name, so registration order relative to document registration does not matter.
Types ¶
type Role ¶
type Role struct {
schema.BaseDocument
RoleName string `oj:"required,unique"`
}
Role represents a system role definition. See TAD §4.1.
type RolePermission ¶
type RolePermission struct {
schema.BaseDocument
Role schema.Link `oj:"link=Role,required"`
DocType string `oj:"required"`
Read bool
Write bool
Create bool
Delete bool
Submit bool
}
RolePermission represents a granted set of CRUD/Submit permissions for a Role on a DocType. See TAD §4.1.
func (*RolePermission) DocMeta ¶
func (rp *RolePermission) DocMeta() schema.Meta
func (*RolePermission) Get ¶
func (rp *RolePermission) Get(field string) any
type User ¶
type User struct {
schema.BaseDocument
Email string `oj:"required,unique,format=email,searchable"`
FullName string `oj:"required,searchable"`
Password string `oj:"hidden"`
Roles []UserRole `oj:"child_table"`
Active bool `oj:"default=true"`
}
User represents a system user account. See TAD §4.1.