Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
/auth/cas/ -> auth.php (source)

Differences Between: [Versions 310 and 402]

Authentication Plugin: CAS Authentication Authentication using CAS (Central Authentication Server).

Author: Martin Dougiamas
Author: Jerome GUTIERREZ
Author: IƱaki Arenaza
License: http://www.gnu.org/copyleft/gpl.html GNU Public License
File Size: 400 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

auth_plugin_cas:: (2 methods):
  __construct()
  auth_plugin_cas()

name:: (13 methods):
  prevent_local_passwords()
  user_login()
  is_internal()
  can_change_password()
  loginpage_hook()
  connectCAS()
  change_password_url()
  iscreator()
  get_userinfo()
  sync_users()
  logoutpage_hook()
  postlogout_hook()
  loginpage_idp_list()


Class: auth_plugin_cas  - X-Ref

CAS authentication plugin.

__construct()   X-Ref
Constructor.


auth_plugin_cas()   X-Ref
Old syntax of class constructor. Deprecated in PHP7.


Class: name  - X-Ref

prevent_local_passwords()   X-Ref
No description

user_login($username, $password)   X-Ref
Authenticates user against CAS
Returns true if the username and password work and false if they are
wrong or don't exist.

param: string $username The username (with system magic quotes)
param: string $password The password (with system magic quotes)
return: bool Authentication success or failure.

is_internal()   X-Ref
Returns true if this authentication plugin is 'internal'.

return: bool

can_change_password()   X-Ref
Returns true if this authentication plugin can change the user's
password.

return: bool

loginpage_hook()   X-Ref
Authentication choice (CAS or other)
Redirection to the CAS form or to login/index.php
for other authentication


connectCAS()   X-Ref
Connect to the CAS (clientcas connection or proxycas connection)


change_password_url()   X-Ref
Returns the URL for changing the user's pw, or empty if the default can
be used.

return: moodle_url

iscreator($username)   X-Ref
Returns true if user should be coursecreator.

param: mixed $username    username (without system magic quotes)
return: boolean result

get_userinfo($username)   X-Ref
Reads user information from LDAP and returns it as array()

If no LDAP servers are configured, user information has to be
provided via other methods (CSV file, manually, etc.). Return
an empty array so existing user info is not lost. Otherwise,
calls parent class method to get user info.

param: string $username username
return: mixed array with no magic quotes or false on error

sync_users($do_updates=true)   X-Ref
Syncronizes users from LDAP server to moodle user table.

If no LDAP servers are configured, simply return. Otherwise,
call parent class method to do the work.

param: bool $do_updates will do pull in data updates from LDAP if relevant
return: nothing

logoutpage_hook()   X-Ref
Hook for logout page


postlogout_hook($user)   X-Ref
Post logout hook.

Note: this method replace the prelogout_hook method to avoid redirect to CAS logout
before the event userlogout being triggered.

param: stdClass $user clone of USER object object before the user session was terminated

loginpage_idp_list($wantsurl)   X-Ref
Return a list of identity providers to display on the login page.

param: string|moodle_url $wantsurl The requested URL.
return: array List of arrays with keys url, iconurl and name.