Difference between revisions of "Authentication API"

Jump to: navigation, search
(See also)
 
(One intermediate revision by one other user not shown)
Line 13: Line 13:
 
===Mandatory:===
 
===Mandatory:===
  
<code>'''auth_user_login ($username, $password)'''</code>
+
<code>auth_user_login ($username, $password)</code>
  
 
Authenticate username, password with userdatabase.
 
Authenticate username, password with userdatabase.
Line 25: Line 25:
  
  
<code>'''auth_get_userinfo($username)'''</code>
+
<code>auth_get_userinfo($username)</code>
  
 
Query other userinformation from database.
 
Query other userinformation from database.
Line 34: Line 34:
  
  
<code>'''auth_iscreator($username)'''</code>
+
<code>auth_iscreator($username)</code>
  
 
should user have rights to create courses
 
should user have rights to create courses
Line 45: Line 45:
  
  
<code>'''auth_user_exists ($username)'''</code>
+
<code>auth_user_exists ($username)</code>
  
 
Checks if given username exists on external db
 
Checks if given username exists on external db
Line 52: Line 52:
  
  
<code>'''auth_user_create ($userobject,$plainpass)'''</code>
+
<code>auth_user_create ($userobject,$plainpass)</code>
  
 
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 59: Line 59:
  
  
<code>'''auth_user_activate ($username)'''</code>
+
<code>auth_user_activate ($username)</code>
  
 
activate new user after email-address is confirmed
 
activate new user after email-address is confirmed
Line 66: Line 66:
  
  
<code>'''auth_user_disable ($username)'''</code>
+
<code>auth_user_disable ($username)</code>
  
 
deactivate user in external db.
 
deactivate user in external db.
Line 74: Line 74:
 
=== USER INFORMATION AND SYNCRONIZATION ===
 
=== USER INFORMATION AND SYNCRONIZATION ===
  
<code>'''auth_get_userlist ()'''</code>
+
<code>auth_get_userlist ()</code>
  
 
Get list of usernames in external db.
 
Get list of usernames in external db.
Line 81: Line 81:
  
  
<code>'''auth_get_users($filter='*')'''</code>
+
<code>auth_get_users($filter='*')</code>
  
 
Get ALL USEROBJECTS FROM EXTERNAL DB.
 
Get ALL USEROBJECTS FROM EXTERNAL DB.
Line 96: Line 96:
 
* [[Authentication FAQ]]
 
* [[Authentication FAQ]]
  
[[Category:Authentication API]]
 
 
[[Category:Authentication]]
 
[[Category:Authentication]]
 
[[ru:Development:API Аутентификации]]
 

Latest revision as of 07:42, 10 June 2011

The Authentication API describes Moodle's interface functions to authentication plugins. (This page is incomplete , I'll update it after I have phpdoc commented auth/ldap/lib.php)

Most of the functions are from the 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:

The 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


See also