Development:Authentication API: Difference between revisions
Helen Foster (talk | contribs) developer wiki transfer |
|||
| (6 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
==Moodle authentication interface== | ==Moodle authentication interface== | ||
Authentication API This file describes Moodle interface functions to authentication modules. (This page is | Authentication API This file describes Moodle interface functions to authentication modules. (This page is incomplete , I'll update it after I have phpdoc commented auth/ldap/lib.php) | ||
Most of functions are from ldap-authentication module and are not implemented (yet?) on other modules. Please feel free to extend other modules to support same features or roll your own module. | Most of functions are from ldap-authentication module and are not implemented (yet?) on other modules. Please feel free to extend other modules to support same features or roll your own module. | ||
| Line 11: | Line 11: | ||
Basic functions to authenticate users with external db | Basic functions to authenticate users with external db | ||
auth_user_login ($username, $password) | ===Mandatory:=== | ||
'''auth_user_login ($username, $password)''' | |||
Authenticate username, password with userdatabase. | Authenticate username, password with userdatabase. | ||
| Line 19: | Line 20: | ||
Returns: true if the username and password work and false if they don't | Returns: true if the username and password work and false if they don't | ||
Following functions are optional , but if present they | ===Optional:=== | ||
Following functions are optional , but if present they extend module usability with Moodle. | |||
auth_get_userinfo($username) | '''auth_get_userinfo($username)''' | ||
Query other userinformation from database. | Query other userinformation from database. | ||
| Line 29: | Line 32: | ||
Returns: | Returns: | ||
User information in array ( name => value, .... or false in case of error Function honors update-flags so if | |||
$CFG->auth_user_(atribute)_updatelocal | $CFG->auth_user_(atribute)_updatelocal | ||
is present, it will return value | is present, it will return value only if flag is true. | ||
===COURSE CREATING=== | |||
auth_iscreator($username) | '''auth_iscreator($username)''' | ||
should user have rights to create courses | should user have rights to create courses | ||
Returns: True if user | Returns: True if user has rights to create cources otherwise false | ||
USER CREATION | ===USER CREATION=== | ||
Functions that enable | Functions that enable user creation, activation and deactivation from moodle to external database | ||
Checks if given username | '''auth_user_exists ($username)''' | ||
Checks if given username exists on external db | |||
Returns: true if given usernname exist or false | Returns: true if given usernname exist or false | ||
auth_user_create ($userobject,$plainpass) | |||
'''auth_user_create ($userobject,$plainpass)''' | |||
Creates new user to external db. User should be created in inactive stage until confirmed by email. | Creates new user to external db. User should be created in inactive stage until confirmed by email. | ||
| Line 57: | Line 63: | ||
Returns: True on success otherwise false | Returns: True on success otherwise false | ||
auth_user_activate ($username) | |||
'''auth_user_activate ($username)''' | |||
activate new user after email-address is confirmed | activate new user after email-address is confirmed | ||
| Line 63: | Line 70: | ||
Returns: True on success otherwise false | Returns: True on success otherwise false | ||
auth_user_disable ($username) { | |||
'''auth_user_disable ($username) {''' | |||
deactivate user in external db. | deactivate user in external db. | ||
| Line 71: | Line 79: | ||
USER INFORMATION AND SYNCRONIZATION | USER INFORMATION AND SYNCRONIZATION | ||
auth_get_userlist () | |||
'''auth_get_userlist ()''' | |||
Get list of usernames in external db. | Get list of usernames in external db. | ||
| Line 77: | Line 86: | ||
Returns: All usernames in array or false on error. | Returns: All usernames in array or false on error. | ||
auth_get_users($filter='*') | |||
'''auth_get_users($filter='*')''' | |||
Get ALL USEROBJECTS FROM EXTERNAL DB. | Get ALL USEROBJECTS FROM EXTERNAL DB. | ||
| Line 83: | Line 93: | ||
Returns: Array of all users as objects from external db | Returns: Array of all users as objects from external db | ||
[[Category:Developer]] | |||
[[Category:Developer|Authentication API]] | |||
Latest revision as of 18:11, 16 January 2008
Moodle authentication interface
Authentication API This file describes Moodle interface functions to authentication modules. (This page is incomplete , I'll update it after I have phpdoc commented auth/ldap/lib.php)
Most of functions are from ldap-authentication module and are not implemented (yet?) on other modules. Please feel free to extend other modules to support same features or roll your own module.
Some of new function are still tested and are not documented here yet.
Authentication functions
Basic functions to authenticate users with external db
Mandatory:
auth_user_login ($username, $password)
Authenticate username, password with userdatabase.
Returns: true if the username and password work and false if they don't
Optional:
Following functions are optional , but if present they extend module usability with Moodle.
auth_get_userinfo($username)
Query other userinformation from database.
Returns:
User information in array ( name => value, .... or false in case of error Function honors update-flags so if $CFG->auth_user_(atribute)_updatelocal is present, it will return value only if flag is true.
COURSE CREATING
auth_iscreator($username)
should user have rights to create courses
Returns: True if user has rights to create cources otherwise false
USER CREATION
Functions that enable user creation, activation and deactivation from moodle to external database
auth_user_exists ($username)
Checks if given username exists on external db
Returns: true if given usernname exist or false
auth_user_create ($userobject,$plainpass)
Creates new user to external db. User should be created in inactive stage until confirmed by email.
Returns: True on success otherwise false
auth_user_activate ($username)
activate new user after email-address is confirmed
Returns: True on success otherwise false
auth_user_disable ($username) {
deactivate user in external db.
Returns: True on success otherwise false
USER INFORMATION AND SYNCRONIZATION
auth_get_userlist ()
Get list of usernames in external db.
Returns: All usernames in array or false on error.
auth_get_users($filter='*')
Get ALL USEROBJECTS FROM EXTERNAL DB.
Returns: Array of all users as objects from external db