devel:authentication_backends
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
devel:authentication_backends [2011-08-11 12:56] – [Notes] 92.75.19.79 | devel:authentication_backends [2023-09-20 23:10] (current) – cleanup docs about the former authentication backends Klap-in | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== How to write an Authentication Backend ?====== | ||
- | [[: | ||
- | |||
- | If none of the provided [[:auth]] does what you want, you can simply create your own. Backends are stored in the '' | ||
- | |||
- | In your class you need to override a few methods and set some public fields from the [[http:// | ||
- | |||
- | If you write a new backend be sure to share your code with the community! | ||
- | |||
- | ===== Fields to set ===== | ||
- | |||
- | ==== $success | ||
- | |||
- | This simple boolean needs to be set to //true// in your constructor if your auth module was correctly initialized. Use this to notify the frontend if anything went wrong by setting it to //false//. | ||
- | |||
- | ==== $cando ==== | ||
- | |||
- | The $cando field is an associative array of booleans. You need to set the array fields to //true// for all functions your backend provides. Here is a list of keys in $cando and their meaning: | ||
- | |||
- | | addUser | ||
- | | delUser | ||
- | | modLogin | ||
- | | modPass | ||
- | | modName | ||
- | | modMail | ||
- | | modGroups | ||
- | | getUsers | ||
- | | getUserCount| can the number of users be retrieved? | | ||
- | | getGroups | ||
- | | external | ||
- | | logoff | ||
- | |||
- | ===== Required Methods | ||
- | |||
- | Only two functions need to be implemented. But the more you do the more the frontend will be able to do. | ||
- | |||
- | See basic.class.php for the methods' | ||
- | |||
- | ==== Constructor ==== | ||
- | |||
- | Well your class should have a constructor of course :-) Set the fields mentioned above here. | ||
- | |||
- | ==== checkPass($user, | ||
- | |||
- | This function need to check if the given user ($user) exists and the given plaintext password ($pass) is correct. | ||
- | |||
- | ==== getUserData($user) ==== | ||
- | |||
- | Used to return user information like email address and real name. | ||
- | |||
- | Return false or an array with the keys ' | ||
- | ===== Optional Methods ===== | ||
- | |||
- | All these methods are optional and will only be called if the appropriate [[#cando]] fields are set | ||
- | |||
- | |||
- | ==== trustExternal() ==== | ||
- | |||
- | If $cando[' | ||
- | |||
- | The function can be used to authenticate against third party cookies or Apache auth mechanisms and replaces the '' | ||
- | |||
- | Have a look at the [[auth: | ||
- | |||
- | If this function is implemented you may omit all other functions from your module (even the required ones above - except for the constructor of course). | ||
- | |||
- | According to the [[auth: | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $_SERVER[' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | for a description of the $USERINFO variables see the documentation of the GetUserData function.\\ | ||
- | Do not forget to add ' | ||
- | |||
- | ==== logOff() ==== | ||
- | |||
- | If $cando[' | ||
- | |||
- | ==== createUser() ==== | ||
- | |||
- | Creates a user with the provided data. | ||
- | |||
- | ==== modifyUser() ==== | ||
- | |||
- | Modifies a user's data. | ||
- | |||
- | ==== deleteUser() ==== | ||
- | |||
- | Deletes one or more users. | ||
- | |||
- | |||
- | |||
- | ==== getUserCount() ==== | ||
- | |||
- | Returns the number of users matching certain filter criteria. | ||
- | |||
- | |||
- | ==== retrieveUsers() ==== | ||
- | |||
- | Fetches userdata for multiple users matching a certain filter criteria. | ||
- | |||
- | |||
- | ==== addGroup() ==== | ||
- | |||
- | Creates a new Group | ||
- | |||
- | ==== retrieveGroups() | ||
- | |||
- | List all available groups | ||
- | |||
- | ===== Notes ===== | ||
- | |||
- | * The authentication backend does currently not use method visibility (available since PHP 5), therefore all methods are expected to be public | ||
- | * doku.php throws E_NOTICE errors due to undefined $_REQUEST-variables. Avoid setting the error reporting to E_ALL in the authenticiation backend or the classes used by the backend. | ||
- | * Dokuwiki starts a session prior to using the authentication backend. Therefore starting a session with modified settings (e.g. another session path) is not easily possible in the backend. | ||
- | * Your backend (or its framework) cannot use __autoload to include further classes, those classes must be loaded manually via require() |
devel/authentication_backends.1313060201.txt.gz · Last modified: 2011-08-11 12:56 by 92.75.19.79