From 7ded986a5f5aabe2670cd176caeb9d76f8555dca Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Mon, 6 Mar 2023 15:38:50 +0000
Subject: [PATCH] :sparkles: Feat(CAS) - Adds possibility to use CAS 1.6

Adds the possibility to use CAS 1.6.
Add new options in backend configuration.
---
 contrib/openldap/core-fd-conf.schema  | 15 ++++++++++++++-
 plugins/config/class_configInLdap.inc | 22 ++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/contrib/openldap/core-fd-conf.schema b/contrib/openldap/core-fd-conf.schema
index 614a7923a..98f049a17 100644
--- a/contrib/openldap/core-fd-conf.schema
+++ b/contrib/openldap/core-fd-conf.schema
@@ -518,6 +518,19 @@ attributetype ( 1.3.6.1.4.1.38414.8.21.6 NAME 'fdCasVerbose'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
   SINGLE-VALUE )
 
+attributetype ( 1.3.6.1.4.1.38414.8.21.7 NAME 'fdCasLibraryBool'
+  DESC 'FusionDirectory - CAS boolean to activate CAS library >= 1.6'
+  EQUALITY booleanMatch
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
+  SINGLE-VALUE )
+
+attributetype ( 1.3.6.1.4.1.38414.8.21.8 NAME 'fdCasClientServiceName'
+  DESC 'FusionDirectory - CAS client service name'
+  EQUALITY caseExactIA5Match
+  SUBSTR caseExactIA5SubstringsMatch
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
+  SINGLE-VALUE)
+
 # merged from dashboard-fd.schema - Needed by Fusion Directory for dashboard options
 
 attributetype ( 1.3.6.1.4.1.38414.27.1.1 NAME 'fdDashboardPrefix'
@@ -632,7 +645,7 @@ objectclass ( 1.3.6.1.4.1.38414.8.2.1 NAME 'fusionDirectoryConf'
     fdIncrementalModifierStates $
     fdSslCaCertPath $ fdSslKeyPath $ fdSslCertPath $
     fdCasActivated $ fdCasServerCaCertPath $ fdCasHost $ fdCasPort $ fdCasContext $ fdCasVerbose $
-    fdLoginMethod
+    fdLoginMethod $ fdCasLibraryBool $ fdCasClientServiceName
   ) )
 
 objectclass ( 1.3.6.1.4.1.38414.8.2.2 NAME 'fusionDirectoryPluginsConf'
diff --git a/plugins/config/class_configInLdap.inc b/plugins/config/class_configInLdap.inc
index 6f37e9d75..6ff659791 100644
--- a/plugins/config/class_configInLdap.inc
+++ b/plugins/config/class_configInLdap.inc
@@ -247,6 +247,14 @@ class configInLdap extends simplePlugin
             _('Verbose error'), _('Activate verbose errors in phpCAS. Avoid in production.'),
             'fdCasVerbose', FALSE
           ),
+          new BooleanAttribute(
+            _('Library CAS 1.6'), _('Activate if library CAS >= 1.6 is being used.'),
+            'fdCasLibraryBool', FALSE
+          ),
+          new StringAttribute(
+            _('Client service'), _('The client service name'),
+            'fdCasClientServiceName', FALSE
+          ),
         ]
       ],
       'people_and_group' => [
@@ -495,6 +503,18 @@ class configInLdap extends simplePlugin
         ]
       ]
     );
+
+    // CAS boolean case to allow the use of CAS library >= 1.6
+    $this->attributesAccess['fdCasLibraryBool']->setManagedAttributes(
+      [
+        'disable' => [
+          FALSE => [
+            'fdCasClientServiceName',
+          ]
+        ]
+      ]
+    );
+
     $this->attributesAccess['fdLoginMethod']->setManagedAttributes(
       [
         'multiplevalues' => [
@@ -516,6 +536,8 @@ class configInLdap extends simplePlugin
             'fdCasPort',
             'fdCasContext',
             'fdCasVerbose',
+            'fdCasClientServiceName',
+            'fdCasLibraryBool'
           ],
           'nonheader' => [
             'fdHttpHeaderAuthHeaderName',
-- 
GitLab