1<?php 2 3namespace Sabre\DAV\Auth\Backend; 4 5use Sabre\HTTP\RequestInterface; 6use Sabre\HTTP\ResponseInterface; 7 8/** 9 * This is the base class for any authentication object. 10 * 11 * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). 12 * @author Evert Pot (http://evertpot.com/) 13 * @license http://sabre.io/license/ Modified BSD License 14 */ 15interface BackendInterface { 16 17 /** 18 * When this method is called, the backend must check if authentication was 19 * successful. 20 * 21 * The returned value must be one of the following 22 * 23 * [true, "principals/username"] 24 * [false, "reason for failure"] 25 * 26 * If authentication was successful, it's expected that the authentication 27 * backend returns a so-called principal url. 28 * 29 * Examples of a principal url: 30 * 31 * principals/admin 32 * principals/user1 33 * principals/users/joe 34 * principals/uid/123457 35 * 36 * If you don't use WebDAV ACL (RFC3744) we recommend that you simply 37 * return a string such as: 38 * 39 * principals/users/[username] 40 * 41 * @param RequestInterface $request 42 * @param ResponseInterface $response 43 * @return array 44 */ 45 function check(RequestInterface $request, ResponseInterface $response); 46 47 /** 48 * This method is called when a user could not be authenticated, and 49 * authentication was required for the current request. 50 * 51 * This gives you the opportunity to set authentication headers. The 401 52 * status code will already be set. 53 * 54 * In this case of Basic Auth, this would for example mean that the 55 * following header needs to be set: 56 * 57 * $response->addHeader('WWW-Authenticate', 'Basic realm=SabreDAV'); 58 * 59 * Keep in mind that in the case of multiple authentication backends, other 60 * WWW-Authenticate headers may already have been set, and you'll want to 61 * append your own WWW-Authenticate header instead of overwriting the 62 * existing one. 63 * 64 * @param RequestInterface $request 65 * @param ResponseInterface $response 66 * @return void 67 */ 68 function challenge(RequestInterface $request, ResponseInterface $response); 69 70} 71