From da0110d5e85279123e8dde392cb4c926397238bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Noack?= <noack@data-quest.de>
Date: Mon, 29 Jan 2024 10:06:41 +0000
Subject: [PATCH] =?UTF-8?q?Resolve=20#3681=20"ILIAS-Schnittstelle:=20=20Ko?=
 =?UTF-8?q?nfigurationsoption=20"Authentifizierungsplugin=20=C3=BCbernehme?=
 =?UTF-8?q?n"=20hat=20keine=20Auswirkungen"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #3681

Merge request studip/studip!2554
---
 lib/ilias_interface/ConnectedIlias.class.php | 12 +++++--
 lib/ilias_interface/IliasUser.class.php      | 34 +++++++++++---------
 2 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/lib/ilias_interface/ConnectedIlias.class.php b/lib/ilias_interface/ConnectedIlias.class.php
index 6b827839a68..09e15076bd0 100644
--- a/lib/ilias_interface/ConnectedIlias.class.php
+++ b/lib/ilias_interface/ConnectedIlias.class.php
@@ -325,7 +325,6 @@ class ConnectedIlias
         }
         $user_data = $this->user->getUserArray();
         $user_data["login"] = $this->ilias_config['user_prefix'].$user_data["login"];
-        $user_data['auth_mode'] = 'default';
 
         $user_exists = $this->soap_client->lookupUser($user_data["login"]);
         //automatische Zuordnung von bestehenden Ilias Accounts
@@ -351,10 +350,18 @@ class ConnectedIlias
             ($this->user->auth_plugin != 'standard') &&
             ($this->user->auth_plugin == $this->ilias_config['ldap_enable'])) {
             $user_data['external_account'] = $this->user->studip_login;
+            $auth_plugin = StudipAuthAbstract::getInstance($this->user->auth_plugin);
+            if ($auth_plugin instanceof StudipAuthLdap) {
+                $user_data['auth_mode'] = 'ldap';
+            } elseif ($auth_plugin instanceof StudipAuthCAS) {
+                $user_data['auth_mode'] = 'cas';
+            } elseif ($auth_plugin instanceof StudipAuthShib) {
+                $user_data['auth_mode'] = 'shibboleth';
+            }
         }
 
         // set role according to Stud.IP perm
-        if ($GLOBALS['auth']->auth['perm'] === 'root') {
+        if (User::findCurrent()->perms === 'root') {
             $role_id = 2;
         } else {
             $role_id = 4;
@@ -405,7 +412,6 @@ class ConnectedIlias
         if ($update_user->isConnected() && $update_user->id && $this->soap_client->lookupUser($update_user->login)) {
             $user_data = $update_user->getUserArray();
             $user_data["login"] = $this->ilias_config['user_prefix'].$user_data["login"];
-            $user_data['auth_mode'] = 'default';
 
             // set role according to Stud.IP perm
             if ($user->perms == "root") {
diff --git a/lib/ilias_interface/IliasUser.class.php b/lib/ilias_interface/IliasUser.class.php
index 6ee980ab671..5737e65b8f3 100644
--- a/lib/ilias_interface/IliasUser.class.php
+++ b/lib/ilias_interface/IliasUser.class.php
@@ -169,22 +169,24 @@ class IliasUser
     function getUserArray()
     {
         // data for user-account in ILIAS
-        $user_data["id"] = $this->id;
-        $user_data["login"] = $this->studip_login;
-        $user_data["passwd"] = $this->external_password;
-        $user_data["firstname"] = $this->firstname;
-        $user_data["lastname"] = $this->lastname;
-        $user_data["title"] = $this->title;
-        $user_data["gender"] = $this->gender;
-        $user_data["email"] = $this->email;
-        $user_data["street"] = $this->street;
-        $user_data["phone_home"] = $this->phone_home;
-        $user_data["matriculation"] = $this->matriculation;
-        $user_data["time_limit_unlimited"] = 1;
-        $user_data["active"] = 1;
-        $user_data["approve_date"] = date('Y-m-d H:i:s');
-        $user_data["accepted_agreement"] = true;
-        $user_data["agree_date"] = date('Y-m-d H:i:s');
+        $user_data['id'] = $this->id;
+        $user_data['login'] = $this->studip_login;
+        $user_data['passwd'] = $this->external_password;
+        $user_data['firstname'] = $this->firstname;
+        $user_data['lastname'] = $this->lastname;
+        $user_data['title'] = $this->title;
+        $user_data['gender'] = $this->gender;
+        $user_data['email'] = $this->email;
+        $user_data['street'] = $this->street;
+        $user_data['phone_home'] = $this->phone_home;
+        $user_data['matriculation'] = $this->matriculation;
+        $user_data['time_limit_unlimited'] = 1;
+        $user_data['active'] = 1;
+        $user_data['approve_date'] = date('Y-m-d H:i:s');
+        $user_data['accepted_agreement'] = true;
+        $user_data['agree_date'] = date('Y-m-d H:i:s');
+        $user_data['auth_mode'] = 'default';
+        $user_data['external_account'] = '';
         return $user_data;
     }
 
-- 
GitLab