Documentation

Plugin extends ServerPlugin
in package

This plugin provides Authentication for a WebDAV server.

It works by providing a Auth\Backend class. Several examples of these classes can be found in the Backend directory.

It's possible to provide more than one backend to this plugin. If more than one backend was provided, each backend will attempt to authenticate. Only if all backends fail, we throw a 401.

Tags
copyright

Copyright (C) fruux GmbH (https://fruux.com/)

author

Evert Pot (http://evertpot.com/)

license

http://sabre.io/license/ Modified BSD License

Table of Contents

$autoRequireLogin  : mixed
By default this plugin will require that the user is authenticated, and refuse any access if the user is not authenticated.
$backends  : mixed
authentication backends.
$currentPrincipal  : string|null
The currently logged in principal. Will be `null` if nobody is currently logged in.
$loginFailedReasons  : array<string|int, string>|null
List of reasons why login failed for the last login operation.
__construct()  : mixed
Creates the authentication plugin.
addBackend()  : mixed
Adds an authentication backend to the plugin.
beforeMethod()  : bool
This method is called before any HTTP method and forces users to be authenticated.
challenge()  : array<string|int, mixed>
This method sends authentication challenges to the user.
check()  : array<string|int, mixed>
Checks authentication credentials, and logs the user in if possible.
getCurrentPrincipal()  : string|null
Returns the currently logged-in principal.
getFeatures()  : array<string|int, mixed>
This method should return a list of server-features.
getHTTPMethods()  : array<string|int, mixed>
Use this method to tell the server this plugin defines additional HTTP methods.
getLoginFailedReasons()  : array<string|int, string>|null
Returns a list of reasons why login was unsuccessful.
getPluginInfo()  : array<string|int, mixed>
Returns a bunch of meta-data about the plugin.
getPluginName()  : string
Returns a plugin name.
getSupportedReportSet()  : array<string|int, mixed>
Returns a list of reports this plugin supports.
initialize()  : mixed
Initializes the plugin. This function is automatically called by the server.

Properties

$autoRequireLogin

By default this plugin will require that the user is authenticated, and refuse any access if the user is not authenticated.

public mixed $autoRequireLogin = true

If this setting is set to false, we let the user through, whether they are authenticated or not.

This is useful if you want to allow both authenticated and unauthenticated access to your server.

$backends

authentication backends.

protected mixed $backends

$currentPrincipal

The currently logged in principal. Will be `null` if nobody is currently logged in.

protected string|null $currentPrincipal

$loginFailedReasons

List of reasons why login failed for the last login operation.

protected array<string|int, string>|null $loginFailedReasons

Methods

challenge()

This method sends authentication challenges to the user.

public challenge(RequestInterface $request, ResponseInterface $response) : array<string|int, mixed>

This method will for example cause a HTTP Basic backend to set a WWW-Authorization header, indicating to the client that it should authenticate.

Parameters
$request : RequestInterface
$response : ResponseInterface
Return values
array<string|int, mixed>

check()

Checks authentication credentials, and logs the user in if possible.

public check(RequestInterface $request, ResponseInterface $response) : array<string|int, mixed>

This method returns an array. The first item in the array is a boolean indicating if login was successful.

If login was successful, the second item in the array will contain the current principal url/path of the logged in user.

If login was not successful, the second item in the array will contain a an array with strings. The strings are a list of reasons why login was unsuccessful. For every auth backend there will be one reason, so usually there's just one.

Parameters
$request : RequestInterface
$response : ResponseInterface
Return values
array<string|int, mixed>

getCurrentPrincipal()

Returns the currently logged-in principal.

public getCurrentPrincipal() : string|null

This will return a string such as:

principals/username principals/users/username

This method will return null if nobody is logged in.

Return values
string|null

getFeatures()

This method should return a list of server-features.

public getFeatures() : array<string|int, mixed>

This is for example 'versioning' and is added to the DAV: header in an OPTIONS response.

Return values
array<string|int, mixed>

getHTTPMethods()

Use this method to tell the server this plugin defines additional HTTP methods.

public getHTTPMethods(string $path) : array<string|int, mixed>

This method is passed a uri. It should only return HTTP methods that are available for the specified uri.

Parameters
$path : string
Return values
array<string|int, mixed>

getLoginFailedReasons()

Returns a list of reasons why login was unsuccessful.

public getLoginFailedReasons() : array<string|int, string>|null

This method will return the login failed reasons for the last login operation. One for each auth backend.

This method returns null if the last authentication attempt was successful, or if there was no authentication attempt yet.

Return values
array<string|int, string>|null

getPluginInfo()

Returns a bunch of meta-data about the plugin.

public getPluginInfo() : array<string|int, mixed>

Providing this information is optional, and is mainly displayed by the Browser plugin.

The description key in the returned array may contain html and will not be sanitized.

Return values
array<string|int, mixed>

getPluginName()

Returns a plugin name.

public getPluginName() : string

Using this name other plugins will be able to access other plugins using DAV\Server::getPlugin

Return values
string

getSupportedReportSet()

Returns a list of reports this plugin supports.

public getSupportedReportSet(string $uri) : array<string|int, mixed>

This will be used in the {DAV:}supported-report-set property. Note that you still need to subscribe to the 'report' event to actually implement them

Parameters
$uri : string
Return values
array<string|int, mixed>

initialize()

Initializes the plugin. This function is automatically called by the server.

public initialize(Server $server) : mixed
Parameters
$server : Server
Return values
mixed

Search results