@@ -29,7 +29,6 @@ class ilAuthProviderOpenIdConnect extends ilAuthProvider
29
29
private const OIDC_AUTH_IDTOKEN = "oidc_auth_idtoken " ;
30
30
private ilOpenIdConnectSettings $ settings ;
31
31
/** @var array $body */
32
- private $ body ;
33
32
private ilLogger $ logger ;
34
33
private ilLanguage $ lng ;
35
34
@@ -40,7 +39,6 @@ public function __construct(ilAuthCredentials $credentials)
40
39
41
40
$ this ->logger = $ DIC ->logger ()->auth ();
42
41
$ this ->settings = ilOpenIdConnectSettings::getInstance ();
43
- $ this ->body = $ DIC ->http ()->request ()->getParsedBody ();
44
42
$ this ->lng = $ DIC ->language ();
45
43
$ this ->lng ->loadLanguageModule ('auth ' );
46
44
}
@@ -97,7 +95,6 @@ public function doAuthentication(ilAuthStatus $status): bool
97
95
98
96
$ oidc ->authenticate ();
99
97
// user is authenticated, otherwise redirected to authorization endpoint or exception
100
- $ this ->logger ->dump ($ this ->body , ilLogLevel::DEBUG );
101
98
102
99
$ claims = $ oidc ->requestUserInfo ();
103
100
$ this ->logger ->dump ($ claims , ilLogLevel::DEBUG );
@@ -136,10 +133,17 @@ private function handleUpdate(ilAuthStatus $status, $user_info): ilAuthStatus
136
133
}
137
134
138
135
$ uid_field = $ this ->settings ->getUidField ();
139
- $ ext_account = $ user_info ->{$ uid_field };
136
+ $ ext_account = $ user_info ->{$ uid_field } ?? '' ;
140
137
141
- $ this ->logger ->debug ('Authenticated external account: ' . $ ext_account );
138
+ if (!is_string ($ ext_account ) || $ ext_account === '' ) {
139
+ $ this ->logger ->error ('Could not determine valid external account, value is empty or not a string. ' );
140
+ $ this ->logger ->dump ($ user_info , ilLogLevel::ERROR );
141
+ $ status ->setStatus (ilAuthStatus::STATUS_AUTHENTICATION_FAILED );
142
+ $ status ->setReason ('err_wrong_login ' );
143
+ return $ status ;
144
+ }
142
145
146
+ $ this ->logger ->debug ('Authenticated external account: ' . $ ext_account );
143
147
144
148
$ int_account = ilObjUser::_checkExternalAuthAccount (
145
149
ilOpenIdConnectUserSync::AUTH_MODE ,
@@ -148,11 +152,6 @@ private function handleUpdate(ilAuthStatus $status, $user_info): ilAuthStatus
148
152
149
153
try {
150
154
$ sync = new ilOpenIdConnectUserSync ($ this ->settings , $ user_info );
151
- if (!is_string ($ ext_account )) {
152
- $ status ->setStatus (ilAuthStatus::STATUS_AUTHENTICATION_FAILED );
153
- $ status ->setReason ('err_wrong_login ' );
154
- return $ status ;
155
- }
156
155
$ sync ->setExternalAccount ($ ext_account );
157
156
$ sync ->setInternalAccount ((string ) $ int_account );
158
157
$ sync ->updateUser ();
0 commit comments