openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

HttpAuth.class.php (810B)


      1 <?php
      2 
      3 namespace cms\auth;
      4 
      5 use cms\auth\Auth;
      6 use cms\base\Configuration;
      7 use util\Http;
      8 
      9 /**
     10  * HTTP-Authentifzierung.
     11  *
     12  * Das vom Benutzer eingegebene Kennwort wird gegen eine HTTP-Adresse
     13  * geprüft, bei der HTTP-Auth aktiviert ist.
     14  *
     15  * @author Jan Dankert
     16  */
     17 class HttpAuth implements Auth
     18 {
     19 
     20 	/**
     21 	 * Dieses Loginmodul kann keinen Namen feststellen.
     22 	 */
     23 	public function username()
     24 	{
     25 		return null;
     26 	}
     27 
     28 
     29 	/**
     30 	 * Ueberpruefen des Kennwortes.
     31 	 *
     32 	 * Das Kennwort wird gegen einen HTTP-Server geprüft.
     33 	 */
     34 	public function login($user, $password, $token)
     35 	{
     36 		$http = new Http( Configuration::get(['security','http','url']));
     37 		$http->method = 'HEAD';
     38 		$http->setBasicAuthentication($user, $password);
     39 
     40 		$ok = $http->request();
     41 
     42 		return $ok ? Auth::STATUS_SUCCESS : Auth::STATUS_FAILED;
     43 	}
     44 }