mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-58220 oauth2: Add is_configured to issuer
Saves repeated checks for clientid and clientsecret.
This commit is contained in:
parent
5aa0f0ae48
commit
5b0b35c096
3 changed files with 14 additions and 4 deletions
|
@ -85,7 +85,7 @@ class renderer extends plugin_renderer_base {
|
||||||
$namecell->header = true;
|
$namecell->header = true;
|
||||||
|
|
||||||
// Configured.
|
// Configured.
|
||||||
if (!empty($issuer->get('clientid')) && !empty($issuer->get('clientsecret'))) {
|
if ($issuer->is_configured()) {
|
||||||
$configured = $OUTPUT->pix_icon('yes', get_string('configured', 'tool_oauth2'), 'tool_oauth2');
|
$configured = $OUTPUT->pix_icon('yes', get_string('configured', 'tool_oauth2'), 'tool_oauth2');
|
||||||
} else {
|
} else {
|
||||||
$configured = $OUTPUT->pix_icon('no', get_string('notconfigured', 'tool_oauth2'), 'tool_oauth2');
|
$configured = $OUTPUT->pix_icon('no', get_string('notconfigured', 'tool_oauth2'), 'tool_oauth2');
|
||||||
|
|
|
@ -187,9 +187,7 @@ class auth extends \auth_plugin_base {
|
||||||
*/
|
*/
|
||||||
private function is_ready_for_login_page(\core\oauth2\issuer $issuer) {
|
private function is_ready_for_login_page(\core\oauth2\issuer $issuer) {
|
||||||
return $issuer->get('enabled') &&
|
return $issuer->get('enabled') &&
|
||||||
!empty($issuer->get('clientid')) &&
|
$issuer->is_configured() &&
|
||||||
!empty($issuer->get('clientsecret')) &&
|
|
||||||
$issuer->is_authentication_supported() &&
|
|
||||||
!empty($issuer->get('showonloginpage'));
|
!empty($issuer->get('showonloginpage'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,15 @@ class issuer extends persistent {
|
||||||
return (!empty($this->get_endpoint_url('userinfo')));
|
return (!empty($this->get_endpoint_url('userinfo')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if this issuer looks like it has been configured.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function is_configured() {
|
||||||
|
return (!empty($this->get('clientid')) && !empty($this->get('clientsecret')));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does this OAuth service support system authentication?
|
* Does this OAuth service support system authentication?
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
@ -175,6 +184,9 @@ class issuer extends persistent {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function is_system_account_connected() {
|
public function is_system_account_connected() {
|
||||||
|
if (!$this->is_configured()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$sys = system_account::get_record(['issuerid' => $this->get('id')]);
|
$sys = system_account::get_record(['issuerid' => $this->get('id')]);
|
||||||
if (!empty($sys) and !empty($sys->get('refreshtoken'))) {
|
if (!empty($sys) and !empty($sys->get('refreshtoken'))) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue