Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Static Public Member Functions | Static Protected Member Functions | List of all members
core\oauth2\api Class Reference

Static list of api methods for system oauth2 configuration. More...

Static Public Member Functions

static connect_system_account ($issuer, $returnurl)
 Perform the OAuth dance and get a refresh token. More...
 
static create_endpoint ($data)
 Take the data from the mform and create the endpoint. More...
 
static create_endpoints_for_standard_issuer ($type, $issuer)
 Create endpoints for standard issuers, based on the issuer created from submitted data. More...
 
static create_issuer ($data)
 Take the data from the mform and create the issuer. More...
 
static create_standard_issuer ($type, $baseurl=false)
 Create one of the standard issuers. More...
 
static create_user_field_mapping ($data)
 Take the data from the mform and create the user field mapping. More...
 
static delete_endpoint ($id)
 Delete an endpoint. More...
 
static delete_issuer ($id)
 Delete an identity issuer. More...
 
static delete_user_field_mapping ($id)
 Delete a user_field_mapping. More...
 
static disable_issuer ($id)
 Disable an identity issuer. More...
 
static enable_issuer ($id)
 Enable an identity issuer. More...
 
static get_all_issuers ()
 List all the issuers, ordered by the sortorder field. More...
 
static get_endpoint ($id)
 Get a single endpoint by id. More...
 
static get_endpoints (issuer $issuer)
 Get the list of defined endpoints for this OAuth issuer. More...
 
static get_issuer ($id)
 Get a single issuer by id. More...
 
static get_system_account (issuer $issuer)
 Get the system account for an installed OAuth service. More...
 
static get_system_oauth_client (issuer $issuer)
 Get an authenticated oauth2 client using the system account. More...
 
static get_system_scopes_for_issuer ($issuer)
 Get the full list of system scopes required by an oauth issuer. More...
 
static get_user_field_mapping ($id)
 Get a single user field mapping by id. More...
 
static get_user_field_mappings (issuer $issuer)
 Get the list of defined mapping from OAuth user fields to moodle user fields. More...
 
static get_user_oauth_client (issuer $issuer, moodle_url $currenturl, $additionalscopes='')
 Get an authenticated oauth2 client using the current user account. More...
 
static init_standard_issuer ($type)
 Initializes a record for one of the standard issuers to be displayed in the settings. More...
 
static move_down_issuer ($id)
 Reorder this identity issuer. More...
 
static move_up_issuer ($id)
 Reorder this identity issuer. More...
 
static update_endpoint ($data)
 Take the data from the mform and update the endpoint. More...
 
static update_issuer ($data)
 Take the data from the mform and update the issuer. More...
 
static update_user_field_mapping ($data)
 Take the data from the mform and update the user field mapping. More...
 

Static Protected Member Functions

static discover_endpoints ($issuer)
 If the discovery endpoint exists for this issuer, try and determine the list of valid endpoints. More...
 
static guess_image ($issuer)
 Guess an image from the discovery URL. More...
 

Detailed Description

Static list of api methods for system oauth2 configuration.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ connect_system_account()

static core\oauth2\api::connect_system_account (   $issuer,
  $returnurl 
)
static

Perform the OAuth dance and get a refresh token.

Requires moodle/site:config capability at the system context.

Parameters
core\oauth2\issuer$issuer
moodle_url$returnurlThe url to the current page (we will be redirected back here after authentication).
Return values
boolean

◆ create_endpoint()

static core\oauth2\api::create_endpoint (   $data)
static

Take the data from the mform and create the endpoint.

Parameters
stdClass$data
Return values
core

◆ create_endpoints_for_standard_issuer()

static core\oauth2\api::create_endpoints_for_standard_issuer (   $type,
  $issuer 
)
static

Create endpoints for standard issuers, based on the issuer created from submitted data.

Parameters
string$typeOne of google, facebook, microsoft, nextcloud
issuer$issuerissuer the endpoints should be created for.
Return values
core

◆ create_issuer()

static core\oauth2\api::create_issuer (   $data)
static

Take the data from the mform and create the issuer.

Parameters
stdClass$data
Return values
core

◆ create_standard_issuer()

static core\oauth2\api::create_standard_issuer (   $type,
  $baseurl = false 
)
static

Create one of the standard issuers.

Parameters
string$typeOne of google, facebook, microsoft, or nextcloud
string | false$baseurlBaseurl (only required for nextcloud)
Return values
core

◆ create_user_field_mapping()

static core\oauth2\api::create_user_field_mapping (   $data)
static

Take the data from the mform and create the user field mapping.

Parameters
stdClass$data
Return values
core

◆ delete_endpoint()

static core\oauth2\api::delete_endpoint (   $id)
static

Delete an endpoint.

Requires moodle/site:config capability at the system context.

Parameters
int$idThe id of the endpoint to delete.
Return values
boolean

◆ delete_issuer()

static core\oauth2\api::delete_issuer (   $id)
static

Delete an identity issuer.

Requires moodle/site:config capability at the system context.

Parameters
int$idThe id of the identity issuer to delete.
Return values
boolean

◆ delete_user_field_mapping()

static core\oauth2\api::delete_user_field_mapping (   $id)
static

Delete a user_field_mapping.

Requires moodle/site:config capability at the system context.

Parameters
int$idThe id of the user_field_mapping to delete.
Return values
boolean

◆ disable_issuer()

static core\oauth2\api::disable_issuer (   $id)
static

Disable an identity issuer.

Requires moodle/site:config capability at the system context.

Parameters
int$idThe id of the identity issuer to disable.
Return values
boolean

◆ discover_endpoints()

static core\oauth2\api::discover_endpoints (   $issuer)
staticprotected

If the discovery endpoint exists for this issuer, try and determine the list of valid endpoints.

Parameters
issuer$issuer
Return values
intThe number of discovered services.

◆ enable_issuer()

static core\oauth2\api::enable_issuer (   $id)
static

Enable an identity issuer.

Requires moodle/site:config capability at the system context.

Parameters
int$idThe id of the identity issuer to enable.
Return values
boolean

◆ get_all_issuers()

static core\oauth2\api::get_all_issuers ( )
static

List all the issuers, ordered by the sortorder field.

Return values
core

◆ get_endpoint()

static core\oauth2\api::get_endpoint (   $id)
static

Get a single endpoint by id.

Parameters
int$id
Return values
core

◆ get_endpoints()

static core\oauth2\api::get_endpoints ( issuer  $issuer)
static

Get the list of defined endpoints for this OAuth issuer.

Parameters
core\oauth2\issuer$issuerThe desired OAuth issuer
Return values
core

◆ get_issuer()

static core\oauth2\api::get_issuer (   $id)
static

Get a single issuer by id.

Parameters
int$id
Return values
core

◆ get_system_account()

static core\oauth2\api::get_system_account ( issuer  $issuer)
static

Get the system account for an installed OAuth service.

Never ever ever expose this to a webservice because it contains the refresh token which grants API access.

Parameters
core\oauth2\issuer$issuer
Return values
system_account|false

◆ get_system_oauth_client()

static core\oauth2\api::get_system_oauth_client ( issuer  $issuer)
static

Get an authenticated oauth2 client using the system account.

This call uses the refresh token to get an access token.

Parameters
core\oauth2\issuer$issuer
Return values
core

◆ get_system_scopes_for_issuer()

static core\oauth2\api::get_system_scopes_for_issuer (   $issuer)
static

Get the full list of system scopes required by an oauth issuer.

This includes the list required for login as well as any scopes injected by the oauth2_system_scopes callback in plugins.

Parameters
core\oauth2\issuer$issuer
Return values
string

◆ get_user_field_mapping()

static core\oauth2\api::get_user_field_mapping (   $id)
static

Get a single user field mapping by id.

Parameters
int$id
Return values
core

◆ get_user_field_mappings()

static core\oauth2\api::get_user_field_mappings ( issuer  $issuer)
static

Get the list of defined mapping from OAuth user fields to moodle user fields.

Parameters
core\oauth2\issuer$issuerThe desired OAuth issuer
Return values
core

◆ get_user_oauth_client()

static core\oauth2\api::get_user_oauth_client ( issuer  $issuer,
moodle_url  $currenturl,
  $additionalscopes = '' 
)
static

Get an authenticated oauth2 client using the current user account.

This call does the redirect dance back to the current page after authentication.

Parameters
core\oauth2\issuer$issuerThe desired OAuth issuer
moodle_url$currenturlThe url to the current page.
string$additionalscopesThe additional scopes required for authorization.
Return values
core

◆ guess_image()

static core\oauth2\api::guess_image (   $issuer)
staticprotected

Guess an image from the discovery URL.

Parameters
core\oauth2\issuer$issuerThe desired OAuth issuer

◆ init_standard_issuer()

static core\oauth2\api::init_standard_issuer (   $type)
static

Initializes a record for one of the standard issuers to be displayed in the settings.

The issuer is not yet created in the database.

Parameters
string$typeOne of google, facebook, microsoft, nextcloud
Return values
core

◆ move_down_issuer()

static core\oauth2\api::move_down_issuer (   $id)
static

Reorder this identity issuer.

Requires moodle/site:config capability at the system context.

Parameters
int$idThe id of the identity issuer to move.
Return values
boolean

◆ move_up_issuer()

static core\oauth2\api::move_up_issuer (   $id)
static

Reorder this identity issuer.

Requires moodle/site:config capability at the system context.

Parameters
int$idThe id of the identity issuer to move.
Return values
boolean

◆ update_endpoint()

static core\oauth2\api::update_endpoint (   $data)
static

Take the data from the mform and update the endpoint.

Parameters
stdClass$data
Return values
core

◆ update_issuer()

static core\oauth2\api::update_issuer (   $data)
static

Take the data from the mform and update the issuer.

Parameters
stdClass$data
Return values
core

◆ update_user_field_mapping()

static core\oauth2\api::update_user_field_mapping (   $data)
static

Take the data from the mform and update the user field mapping.

Parameters
stdClass$data
Return values
core

The documentation for this class was generated from the following file: