[ Index ]

PHP Cross Reference of DokuWiki




/inc/Extension/ -> AuthPlugin.php (summary)

(no description)

File Size: 458 lines (15 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

AuthPlugin:: (19 methods):

Class: AuthPlugin  - X-Ref

Auth Plugin Prototype

allows to authenticate users in a plugin

__construct()   X-Ref

Carry out sanity checks to ensure the object is
able to operate. Set capabilities in $this->cando
array here

For future compatibility, sub classes should always include a call
to parent::__constructor() in their constructors!

Set $this->success to false if checks fail

author: Christopher Smith <chris@jalakai.co.uk>

getCapabilities()   X-Ref
Available Capabilities. [ DO NOT OVERRIDE ]

For introspection/debugging

return: array
author: Christopher Smith <chris@jalakai.co.uk>

canDo($cap)   X-Ref
Capability check. [ DO NOT OVERRIDE ]

Checks the capabilities set in the $this->cando array and
some pseudo capabilities (shortcutting access to multiple

ususal capabilities start with lowercase letter
shortcut capabilities start with uppercase letter

param: string $cap the capability to check
return: bool
author: Andreas Gohr <andi@splitbrain.org>

triggerUserMod($type, $params)   X-Ref
Trigger the AUTH_USERDATA_CHANGE event and call the modification function. [ DO NOT OVERRIDE ]

You should use this function instead of calling createUser, modifyUser or
deleteUsers directly. The event handlers can prevent the modification, for
example for enforcing a user name schema.

param: string $type Modification type ('create', 'modify', 'delete')
param: array $params Parameters for the createUser, modifyUser or deleteUsers method.
return: bool|null|int Result from the modification function or false if an event handler has canceled the action
author: Gabriel Birke <birke@d-scribe.de>

logOff()   X-Ref
Log off the current user [ OPTIONAL ]

Is run in addition to the ususal logoff method. Should
only be needed when trustExternal is implemented.

see: auth_logoff()
author: Andreas Gohr <andi@splitbrain.org>

trustExternal($user, $pass, $sticky = false)   X-Ref
Do all authentication [ OPTIONAL ]

Set $this->cando['external'] = true when implemented

If this function is implemented it will be used to
authenticate a user - all other DokuWiki internals
will not be used for authenticating, thus
implementing the checkPass() function is not needed

The function can be used to authenticate against third
party cookies or Apache auth mechanisms and replaces
the auth_login() function

The function will be called with or without a set
username. If the Username is given it was called
from the login form and the given credentials might
need to be checked. If no username was given it
the function needs to check if the user is logged in
by other means (cookie, environment).

The function needs to set some globals needed by
DokuWiki like auth_login() does.

param: string $user Username
param: string $pass Cleartext Password
param: bool $sticky Cookie should not expire
return: bool             true on successful auth
see: auth_login()
author: Andreas Gohr <andi@splitbrain.org>

checkPass($user, $pass)   X-Ref
Check user+password [ MUST BE OVERRIDDEN ]

Checks if the given user exists and the given
plaintext password is correct

May be ommited if trustExternal is used.

param: string $user the user name
param: string $pass the clear text password
return: bool
author: Andreas Gohr <andi@splitbrain.org>

getUserData($user, $requireGroups = true)   X-Ref
Return user info [ MUST BE OVERRIDDEN ]

Returns info about the given user needs to contain
at least these fields:

name string  full name of the user
mail string  email address of the user
grps array   list of groups the user is in

param: string $user the user name
param: bool $requireGroups whether or not the returned data must include groups
return: false|array containing user data or false
author: Andreas Gohr <andi@splitbrain.org>

createUser($user, $pass, $name, $mail, $grps = null)   X-Ref
Create a new User [implement only where required/possible]

Returns false if the user already exists, null when an error
occurred and true if everything went well.

The new user HAS TO be added to the default group by this

Set addUser capability when implemented

param: string $user
param: string $pass
param: string $name
param: string $mail
param: null|array $grps
return: bool|null
author: Andreas Gohr <andi@splitbrain.org>

modifyUser($user, $changes)   X-Ref
Modify user data [implement only where required/possible]

Set the mod* capabilities according to the implemented features

param: string $user nick of the user to be changed
param: array $changes array of field/value pairs to be changed (password will be clear text)
return: bool
author: Chris Smith <chris@jalakai.co.uk>

deleteUsers($users)   X-Ref
Delete one or more users [implement only where required/possible]

Set delUser capability when implemented

param: array $users
return: int    number of users deleted
author: Chris Smith <chris@jalakai.co.uk>

getUserCount($filter = array()   X-Ref
Return a count of the number of user which meet $filter criteria
[should be implemented whenever retrieveUsers is implemented]

Set getUserCount capability when implemented

param: array $filter array of field/pattern pairs, empty array for no filter
return: int
author: Chris Smith <chris@jalakai.co.uk>

retrieveUsers($start = 0, $limit = 0, $filter = null)   X-Ref
Bulk retrieval of user data [implement only where required/possible]

Set getUsers capability when implemented

param: int $start index of first user to be returned
param: int $limit max number of users to be returned, 0 for unlimited
param: array $filter array of field/pattern pairs, null for no filter
return: array list of userinfo (refer getUserData for internal userinfo details)
author: Chris Smith <chris@jalakai.co.uk>

addGroup($group)   X-Ref
Define a group [implement only where required/possible]

Set addGroup capability when implemented

param: string $group
return: bool
author: Chris Smith <chris@jalakai.co.uk>

retrieveGroups($start = 0, $limit = 0)   X-Ref
Retrieve groups [implement only where required/possible]

Set getGroups capability when implemented

param: int $start
param: int $limit
return: array
author: Chris Smith <chris@jalakai.co.uk>

isCaseSensitive()   X-Ref
Return case sensitivity of the backend [OPTIONAL]

When your backend is caseinsensitive (eg. you can login with USER and
user) then you need to overwrite this method and return false

return: bool

cleanUser($user)   X-Ref
Sanitize a given username [OPTIONAL]

This function is applied to any user name that is given to
the backend and should also be applied to any user name within
the backend before returning it somewhere.

This should be used to enforce username restrictions.

param: string $user username
return: string the cleaned username
author: Andreas Gohr <andi@splitbrain.org>

cleanGroup($group)   X-Ref
Sanitize a given groupname [OPTIONAL]

This function is applied to any groupname that is given to
the backend and should also be applied to any groupname within
the backend before returning it somewhere.

This should be used to enforce groupname restrictions.

Groupnames are to be passed without a leading '@' here.

param: string $group groupname
return: string the cleaned groupname
author: Andreas Gohr <andi@splitbrain.org>

useSessionCache($user)   X-Ref
Check Session Cache validity [implement only where required/possible]

DokuWiki caches user info in the user's session for the timespan defined
in $conf['auth_security_timeout'].

This makes sure slow authentication backends do not slow down DokuWiki.
This also means that changes to the user database will not be reflected
on currently logged in users.

To accommodate for this, the user manager plugin will touch a reference
file whenever a change is submitted. This function compares the filetime
of this reference file with the time stored in the session.

This reference file mechanism does not reflect changes done directly in
the backend's database through other means than the user manager plugin.

Fast backends might want to return always false, to force rechecks on
each page load. Others might want to use their own checking here. If
unsure, do not override.

param: string $user - The username
return: bool
author: Andreas Gohr <andi@splitbrain.org>