admin

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 37 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExportPoll = 2 * time.Second

exportPoll is how often the CLI asks whether an export is ready.

View Source
var Remote = Opener{
	Prog:  "backd",
	Flags: clicore.Remote,
	Open: func(c *kli.CommandContext) (*Session, error) {
		t, err := clicore.TargetOf(c, false)
		if err != nil {
			return nil, err
		}
		return &Session{t: t, Close: func() {}}, nil
	},
	Note: clicore.AdminAPINote,
}

Remote is the CLI's opener: the realm's admin API on a running backd.

Functions

func ApikeyCreate

func ApikeyCreate(c *kli.CommandContext) error

func ApikeyList

func ApikeyList(c *kli.CommandContext) error

func ApikeyRevoke

func ApikeyRevoke(c *kli.CommandContext) error

func AppConfigGet

func AppConfigGet(c *kli.CommandContext) error

appConfigGet handles `backd app-config get`: every key with its value, or one key.

func AppConfigHistory

func AppConfigHistory(c *kli.CommandContext) error

appConfigHistory handles `backd app-config history`.

func AppConfigReset

func AppConfigReset(c *kli.CommandContext) error

appConfigReset handles `backd app-config reset --keys a,b`.

func AppConfigRollback

func AppConfigRollback(c *kli.CommandContext) error

appConfigRollback handles `backd app-config rollback --version c2`.

func AppConfigSet

func AppConfigSet(c *kli.CommandContext) error

appConfigSet handles `backd app-config set`: one key with --key and --value, or several with --values.

func AuditAction

func AuditAction(c *kli.CommandContext) error

auditAction handles `backd audit`.

func ComplianceScopeCmd

func ComplianceScopeCmd(c *kli.CommandContext) error

complianceScopeCmd handles `backd compliance scope`: what a user's data export takes from each collection, and why anything is left out.

func ConsentsNotify

func ConsentsNotify(c *kli.CommandContext) error

consentsNotify handles `backd consents notify`: ask the users who hold an older version of a consent to review the current one, by email.

func ConsentsRecord

func ConsentsRecord(c *kli.CommandContext) error

consentsRecord handles `backd consents record`: an administrator records a consent a person gave, or withdrew, outside the app, with the evidence for it.

func DataAssignOrg

func DataAssignOrg(c *kli.CommandContext) error

dataAssignOrg gives the documents of a collection that have no organization one.

func DataCheck

func DataCheck(c *kli.CommandContext) error

dataCheck handles `backd data check`: it starts a schema check, follows its progress, prints the reports and exits non-zero when it found drift.

func DataChecks

func DataChecks(c *kli.CommandContext) error

dataChecks handles `backd data checks`: the latest reports (or one in full).

func DataMigrate added in v0.9.11

func DataMigrate(c *kli.CommandContext) error

DataMigrate handles `backd data migrate`: it queues the migration of a collection's documents to its current schema version (workers also do it at every start), and with --wait follows it and exits 0 when every document migrated and 1 when some did not.

func DataMigrations added in v0.9.11

func DataMigrations(c *kli.CommandContext) error

DataMigrations handles `backd data migrations`: every collection with migrations (or one report in full).

func DataTransfer

func DataTransfer(c *kli.CommandContext) error

dataTransfer moves one document to another organization (or out of its organization with --org none), and to a team of it (--team, or --team none), as an administrator.

func EachChunk

func EachChunk(r io.Reader, max int64, fn func(chunk []byte, firstLine int) error) error

eachChunk reads JSON Lines and calls fn with groups of whole lines of up to max bytes (a longer line goes alone), with the number of the first line of the group.

func EncryptMigrate

func EncryptMigrate(c *kli.CommandContext) error

encryptMigrate queues the migration of a collection and follows it.

func EncryptRekey

func EncryptRekey(c *kli.CommandContext) error

encryptRekey starts a new generation of an encrypted field's data key.

func EncryptStatus

func EncryptStatus(c *kli.CommandContext) error

encryptStatus prints, per encrypted field, how its values are stored and how far the migration to the configuration is.

func FileIDsOf

func FileIDsOf(path string, fields []string) ([]string, error)

fileIDsOf lists the ids of the files the documents of a part hold in the given file fields.

func FilesRegenerate

func FilesRegenerate(c *kli.CommandContext) error

filesRegenerate handles `backd files regenerate`: it starts the job that makes the stale image versions of a file field again and follows it.

func FunctionsCancel

func FunctionsCancel(c *kli.CommandContext) error

functionsCancel handles `backd functions cancel`: ends a job that hasn't finished.

func FunctionsHistory

func FunctionsHistory(c *kli.CommandContext) error

functionsHistory handles `backd functions history`.

func FunctionsInvoke

func FunctionsInvoke(c *kli.CommandContext) error

functionsInvoke handles `backd functions invoke`: a normal call to a running backd, through the same route and rules any other caller goes through (not a local shortcut), so what it shows is what production does.

func FunctionsJobs

func FunctionsJobs(c *kli.CommandContext) error

functionsJobs handles `backd functions jobs`: the realm's async and scheduled jobs, newest first, for one function or all of them.

func FunctionsLogs

func FunctionsLogs(c *kli.CommandContext) error

functionsLogs handles `backd functions logs`.

func FunctionsPause

func FunctionsPause(c *kli.CommandContext) error

func FunctionsRerun

func FunctionsRerun(c *kli.CommandContext) error

functionsRerun handles `backd functions rerun`: queues a finished job again.

func FunctionsResume

func FunctionsResume(c *kli.CommandContext) error

func FunctionsSchedules

func FunctionsSchedules(c *kli.CommandContext) error

functionsSchedules handles `backd functions schedules`.

func LocalSettings

func LocalSettings(realm string, getenv func(string) string) *registry.RealmSettings

localSettings returns the realm's settings from CONFIG_DIR, if it is set and loads: run next to the server's config (in its container, say), the CLI can tell which assignments realm.yaml makes.

func OrgsAddMember

func OrgsAddMember(c *kli.CommandContext) error

func OrgsAssignOwner

func OrgsAssignOwner(c *kli.CommandContext) error

func OrgsClaimsSet

func OrgsClaimsSet(c *kli.CommandContext) error

func OrgsCreate

func OrgsCreate(c *kli.CommandContext) error

func OrgsDelete

func OrgsDelete(c *kli.CommandContext) error

func OrgsDomainAdd added in v0.9.13

func OrgsDomainAdd(c *kli.CommandContext) error

func OrgsDomainRemove added in v0.9.13

func OrgsDomainRemove(c *kli.CommandContext) error

func OrgsDomainVerify added in v0.9.13

func OrgsDomainVerify(c *kli.CommandContext) error

func OrgsDomains added in v0.9.13

func OrgsDomains(c *kli.CommandContext) error

func OrgsInvitations

func OrgsInvitations(c *kli.CommandContext) error

func OrgsInvite

func OrgsInvite(c *kli.CommandContext) error

orgsInvite creates an invitation: bound to an address (--email), to a user (--user) or open (--open). It prints the link, which is shown only now.

func OrgsList

func OrgsList(c *kli.CommandContext) error

func OrgsMembers

func OrgsMembers(c *kli.CommandContext) error

func OrgsOwned

func OrgsOwned(c *kli.CommandContext) error

func OrgsReactivate

func OrgsReactivate(c *kli.CommandContext) error

func OrgsRevokeInvitation

func OrgsRevokeInvitation(c *kli.CommandContext) error

func OrgsSSO

func OrgsSSO(c *kli.CommandContext) error

func OrgsSSODelete

func OrgsSSODelete(c *kli.CommandContext) error

func OrgsSSORequiredOff

func OrgsSSORequiredOff(c *kli.CommandContext) error

func OrgsSSOSet

func OrgsSSOSet(c *kli.CommandContext) error

func OrgsSetSlug

func OrgsSetSlug(c *kli.CommandContext) error

func OrgsShow

func OrgsShow(c *kli.CommandContext) error

func PushDevices

func PushDevices(c *UserCtx) error

pushDevices lists a user's registered devices: never their tokens.

func PushRemoveDevice

func PushRemoveDevice(c *UserCtx) error

pushRemoveDevice removes one device of a user; the removal is audited.

func PushSends

func PushSends(c *kli.CommandContext) error

pushSends lists the realm's sends, or shows one with --id.

func PushTest

func PushTest(c *UserCtx) error

pushTest sends one user a test push, audited and counted toward their limits.

func PushWebKeys

func PushWebKeys(c *kli.CommandContext) error

pushWebKeys makes the realm's VAPID key pair: the private key becomes a realm secret, the public one is printed with the realm.yaml snippet. It refuses to replace a key without --rotate, and rotating removes every web device: browsers made their subscriptions under the old public key, so they all need to subscribe again.

func RegisterFieldKeys

func RegisterFieldKeys(sec *kli.CommandBuilder, o Opener)

RegisterFieldKeys adds secret create, rotate and list (the field keys) to sec, through o.

func RegisterTransfer

func RegisterTransfer(cfg *kli.Config, o Opener)

RegisterTransfer adds export and import to cfg, through o.

func SecretDelete

func SecretDelete(c *kli.CommandContext) error

func SecretRef

func SecretRef(scope, name string) string

SecretRef names a secret as function.yaml would: realm.NAME for the realm scope, NAME for a database's, and org:<id>.NAME for an organization's (scope is the database or orgScope).

func SecretSet

func SecretSet(c *kli.CommandContext) error

func StorageCheck

func StorageCheck(c *kli.CommandContext) error

storageCheck handles `backd storage check`: the running backd verifies the realm's storage (it holds the access keys) and the report is printed. Exits 1 when a step failed.

func StorageReconcile

func StorageReconcile(c *kli.CommandContext) error

storageReconcile handles `backd storage reconcile`: the running backd lists the realm's objects and reports (or, with --delete, removes) the ones no document references. It does each storage the realm has (--storage private|public picks one).

func StorageUsage

func StorageUsage(c *kli.CommandContext) error

storageUsage handles `backd storage usage`: what the realm's storage is, whether it works, what the documents hold in it and what waits to be cleaned up.

func TriggersGaps

func TriggersGaps(c *kli.CommandContext) error

triggersGaps handles `backd triggers gaps`.

func TriggersResolve

func TriggersResolve(c *kli.CommandContext) error

triggersResolve handles `backd triggers resolve`.

func TriggersStatus

func TriggersStatus(c *kli.CommandContext) error

triggersStatus handles `backd triggers status`.

func UserChangeEmail

func UserChangeEmail(c *UserCtx) error

func UserCreate

func UserCreate(c *UserCtx) error

func UserDelete

func UserDelete(c *UserCtx) error

func UserExpirePassword

func UserExpirePassword(c *UserCtx) error

func UserExpirePasswords

func UserExpirePasswords(c *UserCtx) error

func UserExport

func UserExport(c *UserCtx) error

userExport handles `backd user export`: it asks for the export of a user's personal data, waits for it, and writes the package (a zip) to --out. The user is told, unless --no-notify and a reason say why not.

func UserExportDownload

func UserExportDownload(c *UserCtx) error

userExportDownload handles `backd user export-download`: it fetches an export made earlier.

func UserIdentities

func UserIdentities(c *UserCtx) error

userIdentities lists the user's sign-in methods.

func UserList

func UserList(c *UserCtx) error

func UserMFAReset

func UserMFAReset(c *UserCtx) error

userMFAReset removes a user's second factor through the admin API.

func UserMFAStatus

func UserMFAStatus(c *UserCtx) error

userMFAStatus shows one user's second factor, or who must still set one up.

func UserNetworks

func UserNetworks(c *UserCtx) error

userNetworks shows or changes a user's network restrictions.

func UserNotifyExpired

func UserNotifyExpired(c *UserCtx) error

func UserOwned

func UserOwned(c *UserCtx) error

userOwned prints what erasing the user would do, per collection with a policy.

func UserPatch

func UserPatch(body map[string]bool, message string) func(*UserCtx) error

userPatch returns a command that changes one field of the user and prints message with the user's email.

func UserResetLink(c *UserCtx) error

func UserRevokeSessions

func UserRevokeSessions(c *UserCtx) error

func UserRole

func UserRole(c *UserCtx, verb, role string) error

func UserSetPassword

func UserSetPassword(c *UserCtx) error

func UserUnlinkIdentity

func UserUnlinkIdentity(c *UserCtx) error

userUnlinkIdentity removes one of the user's sign-in methods.

func WriteSecretFile

func WriteSecretFile(path, content string) error

writeSecretFile writes a file only its owner can read, even if one with wider permissions was there before.

Types

type AuditRecord

type AuditRecord struct {
	ID        string         `json:"id"`
	At        string         `json:"at"`
	Action    string         `json:"action"`
	Actor     string         `json:"actor"`
	Target    *string        `json:"target"`
	Details   map[string]any `json:"details"`
	RequestID *string        `json:"request_id"`
	ClientIP  *string        `json:"client_ip"`
}

type FileRef

type FileRef struct {
	ID      string
	Public  bool
	KeyName string
}

fileRef is a file a document holds, as far as a package needs to know: a public one is imported into the target's public storage, under the name its address ends with.

func FileRefsOf

func FileRefsOf(path string, fields []string) ([]FileRef, error)

fileRefsOf lists the files the documents of a part hold in the given file fields.

type Opener

type Opener struct {
	Prog  string                      // the program: the commands are named "<Prog> export"
	Flags func(cc *kli.CommandConfig) // the flags that say where the realm is
	Open  func(c *kli.CommandContext) (*Session, error)
	Note  string // how the commands reach the realm, ending their help
}

An Opener is where the commands that work on a realm's data through its admin API find it. The CLI's is a running backd (Remote); backd-server's is that same admin handler run in its own process over MongoDB and CONFIG_DIR, with no server (see internal/servercli). Export, import and the field key commands are written once and registered in both trees with their opener.

type Session

type Session struct {
	Close func()
	// BeforeWrite, when set, runs before an import writes anything (backd-server refuses
	// while an instance serves the realm).
	BeforeWrite func(c *kli.CommandContext) error
	// contains filtered or unexported fields
}

A Session is an opened realm.

func InProcess

func InProcess(realm string, h http.Handler, closeFn func(), beforeWrite func(c *kli.CommandContext) error) *Session

InProcess is a session on an admin handler in this process: requests never touch a socket, they are handed to h (see inProcess).

type UserCtx

type UserCtx struct {
	Target *clicore.Target
	Cmd    *kli.CommandContext
	Email  string
	IO     cmdutil.IO
	Local  *registry.RealmSettings // the realm's settings, when CONFIG_DIR has it
}

userCtx is what a user subcommand works with.

Jump to

Keyboard shortcuts

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