", or append "#servicename" to the username passed to a * third-party service). * * If the provider doesn't use a username at all in its * AuthenticationRequests, return null. If the name is syntactically * invalid, it's probably best to return null. * * @param string $username * @return string|null */ public function providerNormalizeUsername( $username ); /** * Revoke the user's credentials * * This may cause the user to no longer exist for the provider, or the user * may continue to exist in a "disabled" state. * * The intention is that the named account will never again be usable for * normal login (i.e. there is no way to undo the revocation of access). * * @param string $username */ public function providerRevokeAccessForUser( $username ); /** * Determine whether a property can change * @see AuthManager::allowsPropertyChange() * @param string $property * @return bool */ public function providerAllowsPropertyChange( $property ); /** * Validate a change of authentication data (e.g. passwords) * * Return StatusValue::newGood( 'ignored' ) if you don't support this * AuthenticationRequest type. * * @param AuthenticationRequest $req * @param bool $checkData If false, $req hasn't been loaded from the * submission so checks on user-submitted fields should be skipped. * $req->username is considered user-submitted for this purpose, even * if it cannot be changed via $req->loadFromSubmission. * @return StatusValue */ public function providerAllowsAuthenticationDataChange( AuthenticationRequest $req, $checkData = true ); /** * Change or remove authentication data (e.g. passwords) * * If $req was returned for AuthManager::ACTION_CHANGE, the corresponding * credentials should result in a successful login in the future. * * If $req was returned for AuthManager::ACTION_REMOVE, the corresponding * credentials should no longer result in a successful login. * * It can be assumed that providerAllowsAuthenticationDataChange with $checkData === true * was called before this, and passed. This method should never fail (other than throwing an * exception). * * @param AuthenticationRequest $req */ public function providerChangeAuthenticationData( AuthenticationRequest $req ); /** * Fetch the account-creation type * @return string One of the TYPE_* constants */ public function accountCreationType(); /** * Determine whether an account creation may begin * * Called from AuthManager::beginAccountCreation() * * @note No need to test if the account exists, AuthManager checks that * @param User $user User being created (not added to the database yet). * This may become a "UserValue" in the future, or User may be refactored * into such. * @param User $creator User doing the creation. This may become a * "UserValue" in the future, or User may be refactored into such. * @param AuthenticationRequest[] $reqs * @return StatusValue */ public function testForAccountCreation( $user, $creator, array $reqs ); /** * Start an account creation flow * @param User $user User being created (not added to the database yet). * This may become a "UserValue" in the future, or User may be refactored * into such. * @param User $creator User doing the creation. This may become a * "UserValue" in the future, or User may be refactored into such. * @param AuthenticationRequest[] $reqs * @return AuthenticationResponse Expected responses: * - PASS: The user may be created. Secondary providers will now run. * - FAIL: The user may not be created. Fail the creation process. * - ABSTAIN: These $reqs are not handled. Some other primary provider may handle it. * - UI: The $reqs are accepted, no other primary provider will run. * Additional AuthenticationRequests are needed to complete the process. * - REDIRECT: The $reqs are accepted, no other primary provider will run. * Redirection to a third party is needed to complete the process. */ public function beginPrimaryAccountCreation( $user, $creator, array $reqs ); /** * Continue an account creation flow * @param User $user User being created (not added to the database yet). * This may become a "UserValue" in the future, or User may be refactored * into such. * @param User $creator User doing the creation. This may become a * "UserValue" in the future, or User may be refactored into such. * @param AuthenticationRequest[] $reqs * @return AuthenticationResponse Expected responses: * - PASS: The user may be created. Secondary providers will now run. * - FAIL: The user may not be created. Fail the creation process. * - UI: Additional AuthenticationRequests are needed to complete the process. * - REDIRECT: Redirection to a third party is needed to complete the process. */ public function continuePrimaryAccountCreation( $user, $creator, array $reqs ); /** * Post-creation callback * * Called after the user is added to the database, before secondary * authentication providers are run. Only called if this provider was the one that issued * a PASS. * * @param User $user User being created (has been added to the database now). * This may become a "UserValue" in the future, or User may be refactored * into such. * @param User $creator User doing the creation. This may become a * "UserValue" in the future, or User may be refactored into such. * @param AuthenticationResponse $response PASS response returned earlier * @return string|null 'newusers' log subtype to use for logging the * account creation. If null, either 'create' or 'create2' will be used * depending on $creator. */ public function finishAccountCreation( $user, $creator, AuthenticationResponse $response ); /** * Post-creation callback * * This will be called at the end of any account creation attempt, regardless of whether this * provider was the one that handled it. It will not be called if the account creation process * results in a session timeout (possibly after a successful user creation, while a secondary * provider is waiting for a response). * * @param User $user User that was attempted to be created. * This may become a "UserValue" in the future, or User may be refactored * into such. * @param User $creator User doing the creation. This may become a * "UserValue" in the future, or User may be refactored into such. * @param AuthenticationResponse $response Authentication response that will be returned * (PASS or FAIL) */ public function postAccountCreation( $user, $creator, AuthenticationResponse $response ); /** * Determine whether an account may be created * * @param User $user User being created (not added to the database yet). * This may become a "UserValue" in the future, or User may be refactored * into such. * @param bool|string $autocreate False if this is not an auto-creation, or * the source of the auto-creation passed to AuthManager::autoCreateUser(). * @param array $options * - flags: (int) Bitfield of User:READ_* constants, default User::READ_NORMAL * - creating: (bool) If false (or missing), this call is only testing if * a user could be created. If set, this (non-autocreation) is for * actually creating an account and will be followed by a call to * testForAccountCreation(). In this case, the provider might return * StatusValue::newGood() here and let the later call to * testForAccountCreation() do a more thorough test. * @return StatusValue */ public function testUserForCreation( $user, $autocreate, array $options = [] ); /** * Post-auto-creation callback * @param User $user User being created (has been added to the database now). * This may become a "UserValue" in the future, or User may be refactored * into such. * @param string $source The source of the auto-creation passed to * AuthManager::autoCreateUser(). */ public function autoCreatedAccount( $user, $source ); /** * Start linking an account to an existing user * @param User $user User being linked. * This may become a "UserValue" in the future, or User may be refactored * into such. * @param AuthenticationRequest[] $reqs * @return AuthenticationResponse Expected responses: * - PASS: The user is linked. * - FAIL: The user is not linked. Fail the linking process. * - ABSTAIN: These $reqs are not handled. Some other primary provider may handle it. * - UI: The $reqs are accepted, no other primary provider will run. * Additional AuthenticationRequests are needed to complete the process. * - REDIRECT: The $reqs are accepted, no other primary provider will run. * Redirection to a third party is needed to complete the process. */ public function beginPrimaryAccountLink( $user, array $reqs ); /** * Continue linking an account to an existing user * @param User $user User being linked. * This may become a "UserValue" in the future, or User may be refactored * into such. * @param AuthenticationRequest[] $reqs * @return AuthenticationResponse Expected responses: * - PASS: The user is linked. * - FAIL: The user is not linked. Fail the linking process. * - UI: Additional AuthenticationRequests are needed to complete the process. * - REDIRECT: Redirection to a third party is needed to complete the process. */ public function continuePrimaryAccountLink( $user, array $reqs ); /** * Post-link callback * * This will be called at the end of any account linking attempt, regardless of whether this * provider was the one that handled it. * * @param User $user User that was attempted to be linked. * This may become a "UserValue" in the future, or User may be refactored * into such. * @param AuthenticationResponse $response Authentication response that will be returned * (PASS or FAIL) */ public function postAccountLink( $user, AuthenticationResponse $response ); }