class Authenticator

The class used to authenticate requests

This is the API class that should be used in other apps.

Properties

private $input
static private $instances
private $account
private $realaccount
private $session
private $client

Methods

Account|null
TryGetAccount()

Returns the authenticated user account (or null)

GetAccount()

Returns the authenticated user account (not null)

Account|null
TryGetRealAccount()

Returns the actual account used for the request, not the masqueraded one (or null)

GetRealAccount()

Returns the actual account used for the request, not the masqueraded one (not null)

bool
isSudoUser()

Returns true if the user is masquering as another user

Session|null
TryGetSession()

Returns the session used for the request (or null)

GetSession()

Returns the session used for the request (not null)

Client|null
TryGetClient()

Returns the client used for the request or null

GetClient()

Returns the client used for the request (not null)

bool
isAdmin()

Returns true if the account used for the request is an admin

bool
isRealAdmin()

Returns true if the real account used for the request is an admin

__construct(Input $input)

No description

static Authenticator|null
TryAuthenticate(ObjectDatabase $database, Input $input, IOInterface $interface)

The primary authentication routine

RequireAdmin()

Requires that the user is an administrator

TryRequireTwoFactor()

Requires that the user posts a twofactor code, if the account uses twofactor

static void
StaticTryRequireTwoFactor(Input $input, Account $account, Session|null $session = null)

No description

RequirePassword()

Requires that the user provides their password

TryRequireCrypto()

Same as RequireCrypto() but does nothing if the account does not have crypto

static void
StaticTryRequireCrypto(Input $input, Account $account, Session|null $session = null)

Same as StaticRequireCrypto() but does nothing if the account does not have crypto

RequireCrypto()

Requires that the account's crypto is unlocked for the request (and exists)

static void
StaticRequireCrypto(Input $input, Account $account, Session|null $session = null)

No description

static void
RequireCryptoFor(Account $account)

Runs TryRequireCrypto() on all instantiated authenticators for $account and throws if not unlocked

Details

at line 64
Account|null TryGetAccount()

Returns the authenticated user account (or null)

Return Value

Account|null

at line 67
Account GetAccount()

Returns the authenticated user account (not null)

Return Value

Account

at line 77
Account|null TryGetRealAccount()

Returns the actual account used for the request, not the masqueraded one (or null)

Return Value

Account|null

at line 80
Account GetRealAccount()

Returns the actual account used for the request, not the masqueraded one (not null)

Return Value

Account

at line 88
bool isSudoUser()

Returns true if the user is masquering as another user

Return Value

bool

at line 93
Session|null TryGetSession()

Returns the session used for the request (or null)

Return Value

Session|null

at line 96
Session GetSession()

Returns the session used for the request (not null)

Return Value

Session

at line 106
Client|null TryGetClient()

Returns the client used for the request or null

Return Value

Client|null

at line 109
Client GetClient()

Returns the client used for the request (not null)

Return Value

Client

at line 117
bool isAdmin()

Returns true if the account used for the request is an admin

Return Value

bool

at line 120
bool isRealAdmin()

Returns true if the real account used for the request is an admin

Return Value

bool

at line 125
private __construct(Input $input)

No description

Parameters

Input $input

the input containing auth details

at line 143
static Authenticator|null TryAuthenticate(ObjectDatabase $database, Input $input, IOInterface $interface)

The primary authentication routine

Loads the specified session, checks validity, updates dates. Note that only a session must be provided, not the client that owns it.

Parameters

ObjectDatabase $database

database reference

Input $input

the input containing auth details

IOInterface $interface

the interface used for the request

Return Value

Authenticator|null

Exceptions

InvalidSessionException

if the given session details are invalid

AccountDisabledException

if the given account is disabled

UnknownAccountException

if the given sudo account is not valid

at line 207
Authenticator RequireAdmin()

Requires that the user is an administrator

Return Value

Authenticator

Exceptions

AdminRequiredException

if not an admin

at line 217
Authenticator TryRequireTwoFactor()

Requires that the user posts a twofactor code, if the account uses twofactor

Return Value

Authenticator

Exceptions

TwoFactorRequiredException

if twofactor was not given

AuthenticationFailedException

if the given twofactor was invalid

at line 225
static void StaticTryRequireTwoFactor(Input $input, Account $account, Session|null $session = null)

No description

Parameters

Input $input
Account $account
Session|null $session

Return Value

void

See also

Authenticator::TryRequireTwoFactor

at line 242
Authenticator RequirePassword()

Requires that the user provides their password

Return Value

Authenticator

Exceptions

PasswordRequiredException

if the password is not given

AuthenticationFailedException

if the password is invalid

at line 260
Authenticator TryRequireCrypto()

Same as RequireCrypto() but does nothing if the account does not have crypto

at line 271
static void StaticTryRequireCrypto(Input $input, Account $account, Session|null $session = null)

Same as StaticRequireCrypto() but does nothing if the account does not have crypto

Parameters

Input $input
Account $account
Session|null $session

Return Value

void

See also

Authenticator::StaticRequireCrypto

at line 283
Authenticator RequireCrypto()

Requires that the account's crypto is unlocked for the request (and exists)

Account crypto can be unlocked via a session, a recovery key, or a password

Return Value

Authenticator

Exceptions

AuthenticationFailedException

if the given keysource is not valid

CryptoKeyRequiredException

if no key source was given

at line 291
static void StaticRequireCrypto(Input $input, Account $account, Session|null $session = null)

No description

Parameters

Input $input
Account $account
Session|null $session

Return Value

void

See also

Authenticator::RequireCrypto

at line 325
static void RequireCryptoFor(Account $account)

Runs TryRequireCrypto() on all instantiated authenticators for $account and throws if not unlocked

Parameters

Account $account

Return Value

void