AccountsApp
class AccountsApp extends InstalledApp
App for managing accounts and authenticating users.
Creates and manages accounts, groups of accounts, authentication, managing and validating contacts. Supports account-crypto, two-factor authentication, multi-client/session management, authentication via external sources, and granular per-account/per-group config.
Properties
| protected | $API | Reference to the main API, for convenience |
from BaseApp |
| static private | $metadata | from BaseApp | |
| protected | $config | from InstalledApp | |
| protected | $database | from InstalledApp |
Methods
Returns an array of strings showing the CLI usage of the app
No description
Return this app's BaseAppLog class name, if used (or null)
Loads a metadata for the given app with the given key
No description
Return the BaseConfig class for this app
Iterates over the list of upgrade scripts, running them sequentially until the DB is up to date with the code
Returns a list of the configured authentication sources
Gets the current account object, or the specified one
Returns the given string with each character after a space capitalized
Enables server-side crypto for an account and returns new recovery keys
Disables server side crypto for an account
Creates a new user account
Creates a new session, and possibly a new client for the account
Creates a set of recovery keys, optionally replacing existing
Creates a two factor authentication source, and recovery keys
Adds a contact to the account
Deletes the current account (and signs out)
Deletes an account session (signing it out)
Deletes an account session and client (signing out fully)
Deletes all registered clients/sessions for an account
Deletes a two factor source for an account
Deletes a contact from an account
Searches for accounts identified with the given name prefix
Searches for groups identified with the given name prefix
Returns a list of all registered accounts
Creates a new account group
Deletes an account group
Gets metadata for an account group membership
Adds a new external authentication source, optionally testing it
Tests an auth source by running an auth query on it
Edits the properties of an existing auth source, optionally testing it
Removes an external auth source, deleting accounts associated with it!
Sends a message to the given account or group's contacts
Adds a new entry to the account create whitelist
Removes an entry from the account create whitelist
Gets all entries in the account whitelist
Details
at line 181
__construct(Main $api)
All apps are constructed when Andromeda runs
at line 193
mixed
Run(Input $input)
Checks if the client is running/needs to run install/upgrade {@inheritDoc}
at line 127
static array
getUsage()
Returns an array of strings showing the CLI usage of the app
at line 117
static string
getName()
No description
at line 119
static protected string|null
getLogClass()
Return this app's BaseAppLog class name, if used (or null)
in
BaseApp at line 59
static protected
getMetadata(string $app, string $key)
Loads a metadata for the given app with the given key
Loads the app's JSON metadata file but not its code
in
BaseApp at line 77
static array
getAppRequires(string $app)
No description
in
BaseApp at line 83
static string
getAppApiVersion(string $app)
No description
in
BaseApp at line 89
static string
getVersion()
No description
in
BaseApp at line 95
commit()
Tells the app to commit any changes made outside the database
in
BaseApp at line 98
rollback()
Tells the app to rollback any changes made outside the database
at line 125
static protected string
getInstallFlags()
No description
in
InstalledApp at line 108
static protected string
getUpgradeFlags()
No description
in
InstalledApp at line 110
static protected array
getInstallUsage()
No description
at line 121
static protected string
getConfigClass()
Return the BaseConfig class for this app
in
InstalledApp at line 144
protected bool
allowInstall()
Returns true if the user is allowed to install/upgrade
in
InstalledApp at line 151
static protected string
getTemplateFolder()
Returns the path of the app's code folder
in
InstalledApp at line 157
static protected array
getUpgradeScripts()
No description
at line 270
protected
Install(Input $input)
Installs the app by importing its SQL file and creating config
in
InstalledApp at line 207
protected
Upgrade(Input $input)
Iterates over the list of upgrade scripts, running them sequentially until the DB is up to date with the code
at line 123
protected Config
GetConfig()
No description
at line 291
protected array
RunGetConfig(Input $input, Authenticator|null $authenticator)
Gets config for this app
at line 304
protected array
RunSetConfig(Input $input, Authenticator|null $authenticator)
Sets config for this app
at line 317
protected array
GetAuthSources(Input $input, Authenticator|null $authenticator)
Returns a list of the configured authentication sources
at line 334
protected array|null
GetAccount(Input $input, Authenticator|null $authenticator)
Gets the current account object, or the specified one
at line 367
protected void
ChangePassword(Input $input, Authenticator|null $authenticator)
Changes the password for an account
If currently logged in, this changes the password for the user's account (requiring the old one) If not logged in, this allows account recovery by resetting the password via a recovery key.
at line 400
static private string
capitalizeWords(string $str)
Returns the given string with each character after a space capitalized
at line 411
protected void
SetFullName(Input $input, Authenticator|null $authenticator)
Sets the user's full (real) name
at line 425
protected void
EmailRecovery(Input $input)
Emails a recovery key to the user's registered contacts
at line 461
protected array|null
EnableCrypto(Input $input, Authenticator|null $authenticator)
Enables server-side crypto for an account and returns new recovery keys
Deletes any existing recovery keys, requiring two factor if they exist
at line 497
protected void
DisableCrypto(Input $input, Authenticator|null $authenticator)
Disables server side crypto for an account
at line 516
protected array
CreateAccount(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Creates a new user account
at line 591
protected array
CreateSession(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Creates a new session, and possibly a new client for the account
The authentication source for the account must be provided if not local. First locates the account, then checks the password. Possibly creates a new account if it exists on the external auth source. Then checks the client object in use, creating one and checking extra auth if not provided. Account crypto is checked, password age is checked, dates are updated. Then finally, the session is created and the client is returned.
at line 726
protected array
CreateRecoveryKeys(Input $input, Authenticator|null $authenticator)
Creates a set of recovery keys, optionally replacing existing
at line 753
protected array
CreateTwoFactor(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Creates a two factor authentication source, and recovery keys
Also activates crypto for the account, if allowed and not active. Doing so will delete all other sessions for the account.
at line 783
protected void
VerifyTwoFactor(Input $input, Authenticator|null $authenticator)
Verifies a two factor source
at line 804
protected array
CreateContact(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Adds a contact to the account
at line 827
protected void
VerifyContact(Input $input)
Verifies an account contact
at line 842
protected void
DeleteAccount(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes the current account (and signs out)
at line 867
protected void
DeleteSession(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes an account session (signing it out)
at line 895
protected void
DeleteClient(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes an account session and client (signing out fully)
at line 922
protected void
DeleteAllAuth(Input $input, Authenticator|null $authenticator)
Deletes all registered clients/sessions for an account
at line 943
protected void
DeleteTwoFactor(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes a two factor source for an account
If this leaves the account without two factor, crypto is disabled
at line 965
protected void
DeleteContact(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes a contact from an account
at line 988
protected array
EditContact(Input $input, Authenticator|null $authenticator)
Edits a contact for an account
at line 1011
protected array
SearchAccounts(Input $input, Authenticator|null $authenticator)
Searches for accounts identified with the given name prefix
at line 1037
protected array
SearchGroups(Input $input, Authenticator|null $authenticator)
Searches for groups identified with the given name prefix
at line 1061
protected array
ListAccounts(Input $input, Authenticator|null $authenticator)
Returns a list of all registered accounts
at line 1082
protected array
ListGroups(Input $input, Authenticator|null $authenticator)
Returns a list of all registered groups
at line 1101
protected array
CreateGroup(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Creates a new account group
at line 1129
protected array
EditGroup(Input $input, Authenticator|null $authenticator)
Edits properties of an existing group
at line 1163
protected array
GetGroup(Input $input, Authenticator|null $authenticator)
Returns the requested group object
at line 1181
protected void
DeleteGroup(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Deletes an account group
at line 1206
protected array
AddGroupMember(Input $input, Authenticator|null $authenticator)
Adds an account to a group
at line 1236
protected array
RemoveGroupMember(Input $input, Authenticator|null $authenticator)
Removes an account from a group
at line 1268
protected array|null
GetMembership(Input $input, Authenticator|null $authenticator)
Gets metadata for an account group membership
at line 1297
protected array
CreateAuthSource(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Adds a new external authentication source, optionally testing it
This authorizes automatically creating an account for anyone that successfully authenticates against the auth source
at line 1323
protected array
TestAuthSource(Input $input, Authenticator|null $authenticator)
Tests an auth source by running an auth query on it
at line 1349
protected array
EditAuthSource(Input $input, Authenticator|null $authenticator)
Edits the properties of an existing auth source, optionally testing it
at line 1370
protected void
DeleteAuthSource(Input $input, Authenticator|null $authenticator, AccessLog|null $accesslog)
Removes an external auth source, deleting accounts associated with it!
at line 1393
protected array
SetAccountProps(Input $input, Authenticator|null $authenticator)
Sets config on an account
at line 1415
protected array
SetGroupProps(Input $input, Authenticator|null $authenticator)
Sets config on a group
at line 1434
protected void
SendMessage(Input $input, Authenticator|null $authenticator)
Sends a message to the given account or group's contacts
at line 1469
protected array
AddWhitelist(Input $input, Authenticator|null $authenticator)
Adds a new entry to the account create whitelist
at line 1488
protected void
RemoveWhitelist(Input $input, Authenticator|null $authenticator)
Removes an entry from the account create whitelist
at line 1509
protected array
GetWhitelist(Input $input, Authenticator|null $authenticator)
Gets all entries in the account whitelist