Skip to content

Commit 620af77

Browse files
committed
enhance ldap owner group calculation
closes CactuseSecurity#3114
1 parent 1538dc1 commit 620af77

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

roles/database/files/sql/idempotent/fworch-texts.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5285,8 +5285,8 @@ INSERT INTO txt VALUES ('H5639', 'German', 'Hier wird der Meldungstext für
52855285
INSERT INTO txt VALUES ('H5639', 'English', 'Insert customized text for errors in requests to external ticket system.');
52865286
INSERT INTO txt VALUES ('H5640', 'German', 'Auswahl des LDAP-Systems, in dem die Eigentümergruppen gepflegt werden.');
52875287
INSERT INTO txt VALUES ('H5640', 'English', 'Select LDAP system for storing owner groups.');
5288-
INSERT INTO txt VALUES ('H5641', 'German', 'Festlegen des Namensschemas für Eigentümergruppen. Dient zur eindeutigen Identifizierung der LDAP Gruppen. Der Platzhalter wird als @@ExternalAppId@@ definiert.');
5289-
INSERT INTO txt VALUES ('H5641', 'English', 'Define naming convention in order to identify the LDAP group belonging to an owner. The variable is specified as @@ExternalAppId@@.');
5288+
INSERT INTO txt VALUES ('H5641', 'German', 'Definieren Sie eine Namenskonvention, um die LDAP-Gruppe (nicht der volle DN) zu identifizieren, die zu einem Eigentümer gehört. Mindestens eine der Variablen @@AppId@@ oder @@ExternalAppId@@ muss enthalten sein. Optional können Sie auch @@AppPrefix@@ verwenden.');
5289+
INSERT INTO txt VALUES ('H5641', 'English', 'Define naming convention in order to identify the LDAP group (not the full DN) belonging to an owner. At least one of the variables @@AppId@@ or @@ExternalAppId@@ must be included. Optionally you may also use @@AppPrefix@@.');
52905290
INSERT INTO txt VALUES ('H5642', 'German', 'Sollen die LDAP-Gruppen aktiv von FWO gepflegt werden (anlegen/ändern von Gruppenmitgliedern)? Ein Schreibzugriff auf den jeweiligen LDAP-Server ist notwendig.');
52915291
INSERT INTO txt VALUES ('H5642', 'English', 'Shall FWO manage LDAP groups for owners? Write access to the respective LDAP is needed if you choose this option.');
52925292
INSERT INTO txt VALUES ('H5643', 'German', 'DNS-Suche: Wenn gesetzt, werden App-Server-Namen aus dem DNS ergänzt und sind nicht manuell editierbar. Falls kein Name aufgelöst werden kann, wird er aus Präfix und IP-Adresse konstruiert.');

roles/lib/files/FWO.Basics/GlobalConstants.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ public struct GlobalConst
3333
public const string kImportAreaSubnetData = "importAreaSubnetData";
3434
public const string kManual = "manual";
3535
public const string kCSV_ = "CSV_";
36+
public const char kAppIdSeparator = '-';
3637
public const string kModellerGroup = "ModellerGroup_";
37-
public const string kAppIdPlaceholder = "@@ExternalAppId@@";
38+
public const string kFullAppIdPlaceholder = "@@ExternalAppId@@";
39+
public const string kAppIdPlaceholder = "@@AppId@@";
40+
public const string kAppPrefixPlaceholder = "@@AppPrefix@@";
3841
public const string kLdapGroupPattern = kModellerGroup + kAppIdPlaceholder;
3942
public const string kImportChangeNotify = "importChangeNotify";
4043
public const string kExternalRequest = "externalRequest";

roles/middleware/files/FWO.Middleware.Server/AppDataImport.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Novell.Directory.Ldap;
1111
using System.Data;
1212
using System.Text.Json;
13+
using System.Text.RegularExpressions;
1314

1415
namespace FWO.Middleware.Server
1516
{
@@ -273,7 +274,24 @@ private async Task<bool> DeactivateApp(FwoOwner app)
273274

274275
private string GetGroupName(string extAppIdString)
275276
{
276-
return globalConfig.OwnerLdapGroupNames.Replace(GlobalConst.kAppIdPlaceholder, extAppIdString);
277+
// hard-coded GlobalConst.kAppIdSeparator could be moved to settings
278+
279+
if (globalConfig.OwnerLdapGroupNames.Contains(GlobalConst.kFullAppIdPlaceholder))
280+
{
281+
return globalConfig.OwnerLdapGroupNames.Replace(GlobalConst.kFullAppIdPlaceholder, extAppIdString);
282+
}
283+
284+
if (globalConfig.OwnerLdapGroupNames.Contains(GlobalConst.kAppPrefixPlaceholder) &&
285+
globalConfig.OwnerLdapGroupNames.Contains(GlobalConst.kAppIdPlaceholder))
286+
{
287+
string[] parts = extAppIdString.Split(GlobalConst.kAppIdSeparator);
288+
string appPrefix = parts.Length > 0 ? parts[0] : "";
289+
string appId = parts.Length > 1 ? parts[1] : "";
290+
return globalConfig.OwnerLdapGroupNames.Replace(GlobalConst.kAppPrefixPlaceholder, appPrefix).Replace(GlobalConst.kAppIdPlaceholder, appId);
291+
}
292+
Log.WriteInfo("Import App Data", $"Could not find ayn placeholders in group name pattern \"{globalConfig.OwnerLdapGroupNames}\" " +
293+
$"({GlobalConst.kFullAppIdPlaceholder}, {GlobalConst.kAppPrefixPlaceholder}, {GlobalConst.kAppIdPlaceholder} ");
294+
return globalConfig.OwnerLdapGroupNames;
277295
}
278296

279297
private string GetGroupDn(string extAppIdString)

0 commit comments

Comments
 (0)