/** * Construct the OpenID Connect client. * * @return \auth_oidc\oidcclient The constructed client. */ protected function get_oidcclient() { if (empty($this->httpclient) || !$this->httpclient instanceof \auth_oidc\httpclientinterface) { $this->httpclient = new \auth_oidc\httpclient(); } if (empty($this->config->clientid) || empty($this->config->clientsecret)) { throw new \AuthInstanceException(get_string('errorauthnocreds', 'auth.oidc')); } if (empty($this->config->authendpoint) || empty($this->config->tokenendpoint)) { throw new \AuthInstanceException(get_string('errorauthnoendpoints', 'auth.oidc')); } $clientid = isset($this->config->clientid) ? $this->config->clientid : null; $clientsecret = isset($this->config->clientsecret) ? $this->config->clientsecret : null; $redirecturi = $this->config->redirecturi; $resource = isset($this->config->oidcresource) ? $this->config->oidcresource : null; $client = new \auth_oidc\oidcclient($this->httpclient); $client->setcreds($clientid, $clientsecret, $redirecturi, $resource); $client->setendpoints(array('auth' => $this->config->authendpoint, 'token' => $this->config->tokenendpoint)); return $client; }
/** * Construct the OpenID Connect client. * * @return \auth_oidc\oidcclient The constructed client. */ protected function get_oidcclient() { if (empty($this->httpclient) || !$this->httpclient instanceof \auth_oidc\httpclientinterface) { $this->httpclient = new \auth_oidc\httpclient(); } if (empty($this->config->clientid) || empty($this->config->clientsecret)) { throw new \moodle_exception('errorauthnocreds', 'auth_oidc'); } if (empty($this->config->authendpoint) || empty($this->config->tokenendpoint)) { throw new \moodle_exception('errorauthnoendpoints', 'auth_oidc'); } $clientid = isset($this->config->clientid) ? $this->config->clientid : null; $clientsecret = isset($this->config->clientsecret) ? $this->config->clientsecret : null; $redirecturi = new \moodle_url('/auth/oidc/'); $resource = isset($this->config->oidcresource) ? $this->config->oidcresource : null; $client = new \auth_oidc\oidcclient($this->httpclient); $client->setcreds($clientid, $clientsecret, $redirecturi->out(), $resource); $client->setendpoints(['auth' => $this->config->authendpoint, 'token' => $this->config->tokenendpoint]); return $client; }
/** * Construct the OpenID Connect client. * * @return \auth_oidc\oidcclient The constructed client. */ protected function get_oidcclient() { global $CFG; if (empty($this->httpclient) || !$this->httpclient instanceof \auth_oidc\httpclientinterface) { $this->httpclient = new \auth_oidc\httpclient(); } if (empty($this->config->clientid) || empty($this->config->clientsecret)) { throw new \moodle_exception('errorauthnocreds', 'auth_oidc'); } if (empty($this->config->authendpoint) || empty($this->config->tokenendpoint)) { throw new \moodle_exception('errorauthnoendpoints', 'auth_oidc'); } $clientid = isset($this->config->clientid) ? $this->config->clientid : null; $clientsecret = isset($this->config->clientsecret) ? $this->config->clientsecret : null; $redirecturi = !empty($CFG->loginhttps) ? str_replace('http://', 'https://', $CFG->wwwroot) : $CFG->wwwroot; $redirecturi .= '/auth/oidc/'; $resource = isset($this->config->oidcresource) ? $this->config->oidcresource : null; $client = new \auth_oidc\oidcclient($this->httpclient); $client->setcreds($clientid, $clientsecret, $redirecturi, $resource); $client->setendpoints(['auth' => $this->config->authendpoint, 'token' => $this->config->tokenendpoint]); return $client; }