Merged revisions 48361-48363 via svnmerge from

svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq

........
  r48361 | ischommer | 2008-01-21 21:05:53 +1300 (Mon, 21 Jan 2008) | 1 line
  
  documentation
........
  r48362 | ischommer | 2008-01-21 21:07:13 +1300 (Mon, 21 Jan 2008) | 1 line
  
  documentation
........
  r48363 | ischommer | 2008-01-21 21:07:43 +1300 (Mon, 21 Jan 2008) | 1 line
  
  documentation
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@52405 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-04-09 11:17:39 +00:00
parent 051e1bc68b
commit 7ae4a30885
2 changed files with 16 additions and 2 deletions

View File

@ -358,6 +358,8 @@ class Controller extends ViewableData {
/**
* Initialisation function that is run before any action on the controller is called.
*
* @uses BasicAuth::requireLogin()
*/
function init() {
// Test and development sites should be secured, via basic-auth

View File

@ -11,9 +11,22 @@
* @subpackage security
*/
class BasicAuth extends Object {
/**
* Used on test-environments by default,
* but can be explicitly disabled.
*
* @var boolean
*/
static protected $disabled;
/**
* Require basic authentication. Will request a username and password if none is given.
* @param memberValidationFunction A boolean method to call on the member to validate them.
*
* @usedby Controller::init()
* @param string $realm
* @param string|array $permissionCode
* @return Member $member
*/
static function requireLogin($realm, $permissionCode) {
if(self::$disabled) return true;
@ -59,7 +72,6 @@ class BasicAuth extends Object {
return $member;
}
static protected $disabled;
static function disable() {
self::$disabled = true;
}