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 [2013-01-26 00:42] – Klap-in | 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 '' | ||
- | * need to be named ''< | ||
- | * specify a class named '' | ||
- | * Your class should either extend one of the existing backends or the '' | ||
- | |||
- | In your class you need to override a few methods and set some public fields from the [[xref> | ||
- | |||
- | If you write a new backend be sure to share your code with the community! | ||
- | |||
- | ===== Fields to set ===== | ||
- | |||
- | * **'' | ||
- | |||
- | * **'' | ||
- | |||
- | | addUser | ||
- | | delUser | ||
- | | modLogin | ||
- | | modPass | ||
- | | modName | ||
- | | modMail | ||
- | | modGroups | ||
- | | getUsers | ||
- | | getUserCount| can the number of users be retrieved? | | ||
- | | getGroups | ||
- | | external | ||
- | | logoff | ||
- | |||
- | ===== Required Methods | ||
- | |||
- | Only a few functions need to be implemented. But the more you do the more the frontend will be able to do. | ||
- | |||
- | See [[xref> | ||
- | |||
- | * **'' | ||
- | |||
- | * **'' | ||
- | |||
- | * **'' | ||
- | array( | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ) | ||
- | </ | ||
- | |||
- | |||
- | ===== Optional Methods ===== | ||
- | |||
- | All these methods are optional and will **only** be called if the appropriate [[#field to set|$cando]] fields are set | ||
- | |||
- | |||
- | * **'' | ||
- | function trustExternal($user, | ||
- | global $USERINFO; | ||
- | | ||
- | // someone used the login form | ||
- | if(!empty($user)){ | ||
- | // | ||
- | if( ...try to authenticate again your backend...) | ||
- | | ||
- | // here you can handle additional post login actions | ||
- | // for your backend | ||
- | | ||
- | }else{ | ||
- | //invalid credentials - log off | ||
- | msg($lang[' | ||
- | auth_logoff(); | ||
- | return false; | ||
- | } | ||
- | } | ||
- | |||
- | // | ||
- | | ||
- | |||
- | // check where if there is a logged in user e.g from session, | ||
- | // $_SERVER or what your auth backend supplies... | ||
- | |||
- | if( ...check here if there is a logged in user...) { | ||
- | |||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | $USERINFO[' | ||
- | | ||
- | $_SERVER[' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | $_SESSION[DOKU_COOKIE][' | ||
- | | ||
- | return true; | ||
- | }else{ | ||
- | //when needed, logoff explicitly. | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | * **'' | ||
- | |||
- | |||
- | * **'' | ||
- | |||
- | * **'' | ||
- | |||
- | * **'' | ||
- | |||
- | |||
- | |||
- | * **'' | ||
- | |||
- | |||
- | * **'' | ||
- | |||
- | |||
- | * **'' | ||
- | |||
- | * **'' | ||
- | |||
- | * **'' | ||
- | |||
- | * **'' | ||
- | |||
- | * **'' | ||
- | |||
- | * **'' | ||
- | |||
- | ===== 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. | ||
- | * Your authentication backend may be called from different working directories (e.g. dokuwiki root or /inc/auth). Keep this in mind if your backend includes or loades other files. | ||
- | * Dokuwiki starts a session prior to using the authentication backend. If your framework uses specific session settings (e.g. another session path) use '' | ||
- | * Your backend (or its framework) cannot use __autoload to include further classes, those classes must be loaded manually via require() |
devel/authentication_backends.1359157332.txt.gz · Last modified: 2013-01-26 00:42 by Klap-in