Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 402] [Versions 400 and 403]
Class for loading/storing oauth2 endpoints from the DB.
Copyright: | 2017 Damyon Wiese |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 650 lines (22 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
api:: (31 methods):
init_standard_issuer()
create_endpoints_for_standard_issuer()
create_standard_issuer()
get_all_issuers()
get_issuer()
get_endpoint()
get_user_field_mapping()
get_system_account()
get_system_scopes_for_issuer()
get_system_oauth_client()
get_user_oauth_client()
get_client_classname()
get_endpoints()
get_user_field_mappings()
guess_image()
update_issuer()
create_issuer()
create_or_update_issuer()
get_service_classname()
update_endpoint()
create_endpoint()
update_user_field_mapping()
create_user_field_mapping()
move_up_issuer()
move_down_issuer()
disable_issuer()
enable_issuer()
delete_issuer()
delete_endpoint()
delete_user_field_mapping()
connect_system_account()
init_standard_issuer($type) X-Ref |
Initializes a record for one of the standard issuers to be displayed in the settings. The issuer is not yet created in the database. return: \core\oauth2\issuer param: string $type One of google, facebook, microsoft, nextcloud, imsobv2p1 |
create_endpoints_for_standard_issuer($type, $issuer) X-Ref |
Create endpoints for standard issuers, based on the issuer created from submitted data. return: \core\oauth2\issuer param: string $type One of google, facebook, microsoft, nextcloud, imsobv2p1 param: issuer $issuer issuer the endpoints should be created for. |
create_standard_issuer($type, $baseurl = false) X-Ref |
Create one of the standard issuers. return: \core\oauth2\issuer param: string $type One of google, facebook, microsoft, nextcloud or imsobv2p1 param: string|false $baseurl Baseurl (only required for nextcloud and imsobv2p1) |
get_all_issuers(bool $includeloginonly = false) X-Ref |
List all the issuers, ordered by the sortorder field return: \core\oauth2\issuer[] param: bool $includeloginonly also include issuers that are configured to be shown only on login page, |
get_issuer($id) X-Ref |
Get a single issuer by id. return: \core\oauth2\issuer param: int $id |
get_endpoint($id) X-Ref |
Get a single endpoint by id. return: \core\oauth2\endpoint param: int $id |
get_user_field_mapping($id) X-Ref |
Get a single user field mapping by id. return: \core\oauth2\user_field_mapping param: int $id |
get_system_account(issuer $issuer) X-Ref |
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. return: system_account|false param: \core\oauth2\issuer $issuer |
get_system_scopes_for_issuer($issuer) X-Ref |
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. return: string param: \core\oauth2\issuer $issuer |
get_system_oauth_client(issuer $issuer) X-Ref |
Get an authenticated oauth2 client using the system account. This call uses the refresh token to get an access token. return: \core\oauth2\client|false An authenticated client (or false if the token could not be upgraded) param: \core\oauth2\issuer $issuer |
get_user_oauth_client(issuer $issuer, moodle_url $currenturl, $additionalscopes = '',$autorefresh = false) X-Ref |
Get an authenticated oauth2 client using the current user account. This call does the redirect dance back to the current page after authentication. return: \core\oauth2\client param: \core\oauth2\issuer $issuer The desired OAuth issuer param: moodle_url $currenturl The url to the current page. param: string $additionalscopes The additional scopes required for authorization. param: bool $autorefresh Should the client support the use of refresh tokens to persist access across sessions. |
get_client_classname(?string $type) X-Ref |
Get the client classname for an issuer. return: string The classname for the custom client or core client class if the class for the defined type param: string $type The OAuth issuer type (google, facebook...). |
get_endpoints(issuer $issuer) X-Ref |
Get the list of defined endpoints for this OAuth issuer return: \core\oauth2\endpoint[] param: \core\oauth2\issuer $issuer The desired OAuth issuer |
get_user_field_mappings(issuer $issuer) X-Ref |
Get the list of defined mapping from OAuth user fields to moodle user fields. return: \core\oauth2\user_field_mapping[] param: \core\oauth2\issuer $issuer The desired OAuth issuer |
guess_image($issuer) X-Ref |
Guess an image from the discovery URL. param: \core\oauth2\issuer $issuer The desired OAuth issuer |
update_issuer($data) X-Ref |
Take the data from the mform and update the issuer. return: \core\oauth2\issuer param: stdClass $data |
create_issuer($data) X-Ref |
Take the data from the mform and create the issuer. return: \core\oauth2\issuer param: stdClass $data |
create_or_update_issuer($data, bool $create) X-Ref |
Take the data from the mform and create or update the issuer. return: issuer The created/updated issuer. param: stdClass $data Form data for them issuer to be created/updated. param: bool $create If true, the issuer will be created; otherwise, it will be updated. |
get_service_classname(?string $type) X-Ref |
Get the service classname for an issuer. return: string The classname for this issuer or "Custom" service class if the class for the defined type doesn't exist param: string $type The OAuth issuer type (google, facebook...). |
update_endpoint($data) X-Ref |
Take the data from the mform and update the endpoint. return: \core\oauth2\endpoint param: stdClass $data |
create_endpoint($data) X-Ref |
Take the data from the mform and create the endpoint. return: \core\oauth2\endpoint param: stdClass $data |
update_user_field_mapping($data) X-Ref |
Take the data from the mform and update the user field mapping. return: \core\oauth2\user_field_mapping param: stdClass $data |
create_user_field_mapping($data) X-Ref |
Take the data from the mform and create the user field mapping. return: \core\oauth2\user_field_mapping param: stdClass $data |
move_up_issuer($id) X-Ref |
Reorder this identity issuer. Requires moodle/site:config capability at the system context. return: boolean param: int $id The id of the identity issuer to move. |
move_down_issuer($id) X-Ref |
Reorder this identity issuer. Requires moodle/site:config capability at the system context. return: boolean param: int $id The id of the identity issuer to move. |
disable_issuer($id) X-Ref |
Disable an identity issuer. Requires moodle/site:config capability at the system context. return: boolean param: int $id The id of the identity issuer to disable. |
enable_issuer($id) X-Ref |
Enable an identity issuer. Requires moodle/site:config capability at the system context. return: boolean param: int $id The id of the identity issuer to enable. |
delete_issuer($id) X-Ref |
Delete an identity issuer. Requires moodle/site:config capability at the system context. return: boolean param: int $id The id of the identity issuer to delete. |
delete_endpoint($id) X-Ref |
Delete an endpoint. Requires moodle/site:config capability at the system context. return: boolean param: int $id The id of the endpoint to delete. |
delete_user_field_mapping($id) X-Ref |
Delete a user_field_mapping. Requires moodle/site:config capability at the system context. return: boolean param: int $id The id of the user_field_mapping to delete. |
connect_system_account($issuer, $returnurl) X-Ref |
Perform the OAuth dance and get a refresh token. Requires moodle/site:config capability at the system context. return: boolean param: \core\oauth2\issuer $issuer param: moodle_url $returnurl The url to the current page (we will be redirected back here after authentication). |