Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

Anobody can login with any password.

Copyright: 2017 Damyon Wiese
License: http://www.gnu.org/copyleft/gpl.html GNU Public License
File Size: 631 lines (24 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: auth  - X-Ref

Plugin for oauth2 authentication.

__construct()   X-Ref
Constructor.


user_login($username, $password)   X-Ref
Returns true if the username and password work or don't exist and false
if the user exists and the password is wrong.

param: string $username The username
param: string $password The password
return: bool Authentication success or failure.

prevent_local_passwords()   X-Ref
We don't want to allow users setting an internal password.

return: bool

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

return: bool

is_synchronised_with_external()   X-Ref
Indicates if moodle should automatically update internal user
records with data from external sources using the information
from auth_plugin_base::get_userinfo().

return: bool true means automatically copy data from ext to user table

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

return: bool

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

can_reset_password()   X-Ref
Returns true if plugin allows resetting of internal password.

return: bool

can_be_manually_set()   X-Ref
Returns true if plugin can be manually set.

return: bool

get_userinfo($username)   X-Ref
Return the userinfo from the oauth handshake. Will only be valid
for the logged in user.

param: string $username

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.

set_static_user_info($userinfo)   X-Ref
Statically cache the user info from the oauth handshake

param: stdClass $userinfo

get_static_user_info()   X-Ref
Get the static cached user info

return: stdClass

set_static_user_picture($userpicture)   X-Ref
Statically cache the user picture from the oauth handshake

param: string $userpicture

get_static_user_picture()   X-Ref
Get the static cached user picture

return: string

update_picture($user)   X-Ref
If this user has no picture - but we got one from oauth - set it.

param: stdClass $user
return: boolean True if the image was updated.

update_user(array $externaldata, $userdata)   X-Ref
Update user data according to data sent by authorization server.

param: array $externaldata data from authorization server
param: stdClass $userdata Current data of the user to be updated
return: stdClass The updated user record, or the existing one if there's nothing to be updated.

user_confirm($username, $confirmsecret)   X-Ref
Confirm the new user as registered.

param: string $username
param: string $confirmsecret

print_confirm_required($title, $message)   X-Ref
Print a page showing that a confirm email was sent with instructions.

param: string $title
param: string $message

complete_login(client $client, $redirecturl)   X-Ref
Complete the login process after oauth handshake is complete.

param: \core\oauth2\client $client
param: string $redirecturl
return: void Either redirects or throws an exception

get_password_change_info(stdClass $user)   X-Ref
Returns information on how the specified user can change their password.
The password of the oauth2 accounts is not stored in Moodle.

param: stdClass $user A user object
return: string[] An array of strings with keys subject and message