2007-09-14 05:12:21 +02:00
|
|
|
<?php
|
2016-06-23 01:37:22 +02:00
|
|
|
|
|
|
|
namespace SilverStripe\Security;
|
|
|
|
|
2017-06-22 12:50:45 +02:00
|
|
|
use SilverStripe\Control\HTTPRequest;
|
2017-05-30 09:42:00 +02:00
|
|
|
use SilverStripe\ORM\ValidationResult;
|
2017-06-09 05:07:35 +02:00
|
|
|
use SilverStripe\Security\MemberAuthenticator\LoginHandler;
|
|
|
|
use SilverStripe\Security\MemberAuthenticator\LogoutHandler;
|
2016-06-23 01:37:22 +02:00
|
|
|
|
2007-09-14 05:12:21 +02:00
|
|
|
/**
|
|
|
|
* Abstract base class for an authentication method
|
|
|
|
*
|
|
|
|
* This class is used as a base class for the different authentication
|
|
|
|
* methods like {@link MemberAuthenticator} or {@link OpenIDAuthenticator}.
|
|
|
|
*
|
|
|
|
* @author Markus Lanthaler <markus@silverstripe.com>
|
|
|
|
*/
|
2017-04-22 06:30:10 +02:00
|
|
|
interface Authenticator
|
2016-11-29 00:31:16 +01:00
|
|
|
{
|
2017-06-15 04:20:12 +02:00
|
|
|
/**
|
|
|
|
* Can log a user in
|
|
|
|
*/
|
2017-04-22 06:30:10 +02:00
|
|
|
const LOGIN = 1;
|
2017-06-15 04:20:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Can log user out
|
|
|
|
*/
|
2017-04-22 06:30:10 +02:00
|
|
|
const LOGOUT = 2;
|
2017-06-15 04:20:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Can change password (check + reset)
|
|
|
|
*/
|
2017-04-22 06:30:10 +02:00
|
|
|
const CHANGE_PASSWORD = 4;
|
2017-06-15 04:20:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Can modify password
|
|
|
|
*/
|
2017-04-22 06:30:10 +02:00
|
|
|
const RESET_PASSWORD = 8;
|
2017-06-15 04:20:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* In-CMS authentication
|
|
|
|
*/
|
2017-04-22 06:30:10 +02:00
|
|
|
const CMS_LOGIN = 16;
|
2016-11-29 00:31:16 +01:00
|
|
|
|
2017-06-15 04:20:12 +02:00
|
|
|
/**
|
|
|
|
* Can check password is valid without logging the user in or modifying the password
|
|
|
|
*/
|
|
|
|
const CHECK_PASSWORD = 32;
|
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
2017-04-22 06:30:10 +02:00
|
|
|
* Returns the services supported by this authenticator
|
2016-11-29 00:31:16 +01:00
|
|
|
*
|
2017-04-22 06:30:10 +02:00
|
|
|
* The number should be a bitwise-OR of 1 or more of the following constants:
|
|
|
|
* Authenticator::LOGIN, Authenticator::LOGOUT, Authenticator::CHANGE_PASSWORD,
|
|
|
|
* Authenticator::RESET_PASSWORD, or Authenticator::CMS_LOGIN
|
2016-11-29 00:31:16 +01:00
|
|
|
*
|
2017-04-22 06:30:10 +02:00
|
|
|
* @return int
|
2016-11-29 00:31:16 +01:00
|
|
|
*/
|
2017-04-22 06:30:10 +02:00
|
|
|
public function supportedServices();
|
2016-11-29 00:31:16 +01:00
|
|
|
|
|
|
|
/**
|
2017-04-22 06:30:10 +02:00
|
|
|
* Return RequestHandler to manage the log-in process.
|
2016-11-29 00:31:16 +01:00
|
|
|
*
|
2017-05-20 06:32:25 +02:00
|
|
|
* The default URL of the RequestHandler should return the initial log-in form, any other
|
2017-04-22 06:30:10 +02:00
|
|
|
* URL may be added for other steps & processing.
|
|
|
|
*
|
|
|
|
* URL-handling methods may return an array [ "Form" => (form-object) ] which can then
|
|
|
|
* be merged into a default controller.
|
2016-11-29 00:31:16 +01:00
|
|
|
*
|
2017-05-20 06:32:25 +02:00
|
|
|
* @param string $link The base link to use for this RequestHandler
|
2017-06-09 05:07:35 +02:00
|
|
|
* @return LoginHandler
|
2016-11-29 00:31:16 +01:00
|
|
|
*/
|
2017-04-22 06:30:10 +02:00
|
|
|
public function getLoginHandler($link);
|
2016-11-29 00:31:16 +01:00
|
|
|
|
2017-05-20 06:32:25 +02:00
|
|
|
/**
|
|
|
|
* Return the RequestHandler to manage the log-out process.
|
|
|
|
*
|
|
|
|
* The default URL of the RequestHandler should log the user out immediately and destroy the session.
|
|
|
|
*
|
|
|
|
* @param string $link The base link to use for this RequestHandler
|
2017-06-09 05:07:35 +02:00
|
|
|
* @return LogoutHandler
|
2017-05-20 06:32:25 +02:00
|
|
|
*/
|
|
|
|
public function getLogOutHandler($link);
|
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
2017-04-22 06:30:10 +02:00
|
|
|
* Return RequestHandler to manage the change-password process.
|
|
|
|
*
|
|
|
|
* The default URL of the RequetHandler should return the initial change-password form,
|
|
|
|
* any other URL may be added for other steps & processing.
|
2016-11-29 00:31:16 +01:00
|
|
|
*
|
2017-04-22 06:30:10 +02:00
|
|
|
* URL-handling methods may return an array [ "Form" => (form-object) ] which can then
|
|
|
|
* be merged into a default controller.
|
|
|
|
*
|
2017-04-30 05:17:26 +02:00
|
|
|
* @param string $link The base link to use for this RequestHnadler
|
2016-11-29 00:31:16 +01:00
|
|
|
*/
|
2017-04-22 06:30:10 +02:00
|
|
|
public function getChangePasswordHandler($link);
|
2017-05-17 07:40:13 +02:00
|
|
|
|
2017-05-20 06:32:25 +02:00
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
2017-06-09 05:07:35 +02:00
|
|
|
* @param string $link
|
2017-05-30 09:42:00 +02:00
|
|
|
* @return mixed
|
2016-11-29 00:31:16 +01:00
|
|
|
*/
|
2017-04-22 06:30:10 +02:00
|
|
|
public function getLostPasswordHandler($link);
|
2016-11-29 00:31:16 +01:00
|
|
|
|
|
|
|
/**
|
2017-04-22 06:30:10 +02:00
|
|
|
* Method to authenticate an user.
|
2016-11-29 00:31:16 +01:00
|
|
|
*
|
2017-04-22 06:30:10 +02:00
|
|
|
* @param array $data Raw data to authenticate the user.
|
2017-06-22 12:50:45 +02:00
|
|
|
* @param HTTPRequest $request
|
2017-05-30 09:42:00 +02:00
|
|
|
* @param ValidationResult $result A validationresult which is either valid or contains the error message(s)
|
2017-04-22 06:30:10 +02:00
|
|
|
* @return Member The matched member, or null if the authentication fails
|
2016-11-29 00:31:16 +01:00
|
|
|
*/
|
2017-06-22 12:50:45 +02:00
|
|
|
public function authenticate(array $data, HTTPRequest $request, ValidationResult &$result = null);
|
2017-06-15 04:20:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the passed password matches the stored one (if the member is not locked out).
|
|
|
|
*
|
|
|
|
* Note, we don't return early, to prevent differences in timings to give away if a member
|
|
|
|
* password is invalid.
|
|
|
|
*
|
|
|
|
* @param Member $member
|
|
|
|
* @param string $password
|
|
|
|
* @param ValidationResult $result
|
|
|
|
* @return ValidationResult
|
|
|
|
*/
|
2017-06-15 07:25:23 +02:00
|
|
|
public function checkPassword(Member $member, $password, ValidationResult &$result = null);
|
2007-09-14 05:12:21 +02:00
|
|
|
}
|