19declare(strict_types=1);
21use Jumbojett\OpenIDConnectClient;
40 $this->
logger = $DIC->logger()->auth();
42 $this->
lng = $DIC->language();
43 $this->
lng->loadLanguageModule(
'auth');
53 $this->
logger->debug(
'Logging out with token: ' . $id_token);
55 if (isset($id_token) && $id_token !==
'') {
63 }
catch (\Jumbojett\OpenIDConnectClientException
$e) {
64 $this->
logger->warning(
'Logging out of OIDC provider failed with: ' . $e->getMessage());
74 $this->
logger->info(
'Authentication aborted, OIDC authentication is disabled');
80 $oidc->setRedirectURL(ILIAS_HTTP_PATH .
'/openidconnect.php');
83 if ($proxy->isActive()) {
84 $host = $proxy->getHost();
85 $port = $proxy->getPort();
89 $oidc->setHttpProxy($host);
94 $oidc->getRedirectURL()
97 $oidc->addScope($this->
settings->getAllScopes());
99 $oidc->addAuthParam([
'prompt' =>
'login']);
102 $oidc->authenticate();
105 $claims = $oidc->getVerifiedClaims();
116 }
catch (Exception
$e) {
117 $this->
logger->warning($e->getMessage());
118 $this->
logger->warning((
string) $e->getCode());
130 if (!is_object($user_info)) {
131 $this->
logger->error(
'Received invalid user credentials: ');
134 $status->
setReason(self::ERR_AUTH_WRONG_LOGIN);
138 $uid_field = $this->
settings->getUidField();
139 $ext_account = $user_info->{$uid_field} ??
'';
141 if (!is_string($ext_account) || $ext_account ===
'') {
142 $this->
logger->error(
'Could not determine valid external account, value is empty or not a string.');
145 $status->setReason(self::ERR_AUTH_WRONG_LOGIN);
149 $this->
logger->debug(
'Authenticated external account: ' . $ext_account);
158 $sync->setExternalAccount($ext_account);
159 $sync->setInternalAccount((
string) $int_account);
164 $status->setAuthenticatedUserId(
$user_id);
169 $status->setReason(self::ERR_AUTH_WRONG_LOGIN);
177 $oidc =
new OpenIDConnectClient(
179 $this->settings->getClientId(),
180 $this->settings->getSecret()
183 $oidc->setCodeChallengeMethod(
'S256');
doAuthentication(ilAuthStatus $status)
const ERR_AUTH_WRONG_LOGIN
readonly ilLogger $logger
readonly ilOpenIdConnectSettings $settings
handleUpdate(ilAuthStatus $status, $user_info)
__construct(ilAuthCredentials $credentials)
ilAuthCredentials $credentials
setTranslatedReason(string $a_reason)
Set translated reason.
const int STATUS_AUTHENTICATION_FAILED
setReason(string $a_reason)
Set reason.
setStatus(int $a_status)
Set auth status.
const int STATUS_AUTHENTICATED
const int AUTH_OPENID_CONNECT
Component logger with individual log levels by component id.
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user
const LOGOUT_SCOPE_GLOBAL
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
static logoutUrl(array $parameters=[])
Return the logout URL with a valid CSRF token.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc