Skip to content

Commit

Permalink
Ticket #760 : Fix different issues
Browse files Browse the repository at this point in the history
  • Loading branch information
thabart committed Jun 19, 2024
1 parent 58d6e58 commit 2c65b52
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ namespace SimpleIdServer.Configuration
{
public static class DisplayConditionEvaluator
{
public static bool IsValid(Dictionary<string, string> values, string condition)
public static bool IsLogicalOperationValid(Dictionary<string, string> values, string condition)
{
if (string.IsNullOrWhiteSpace(condition)) return true;
var conditions = condition.Split("&&").Select(c => c.Trim());
return conditions.All(c => IsEqualityOperationValid(values, c));
}

public static bool IsEqualityOperationValid(Dictionary<string, string> values, string condition)
{
var splitted = condition.Split('=');
var key = splitted[0];
var value = splitted[1];
return values.Any(kvp => kvp.Key == key && kvp.Value == value);
return values.Any(kvp => kvp.Key == key && kvp.Value.Equals(value, System.StringComparison.InvariantCultureIgnoreCase));
}
}
}
2 changes: 1 addition & 1 deletion src/IdServer/SimpleIdServer.IdServer.Fido/MobileOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace SimpleIdServer.IdServer.Fido
{
public class MobileOptions
public class MobileOptions : IFidoOptions
{
/// <summary>
/// Expiration time in seconds of the U2F FIDO session identifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace SimpleIdServer.IdServer.Fido
{
public class WebauthnOptions
public class WebauthnOptions : IFidoOptions
{
/// <summary>
/// Expiration time in seconds of the U2F FIDO session identifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,31 @@ public class LDAPRepresentationsExtractionJobOptions

#region Groups

[ConfigurationRecord("Groups DN", "Full DN of LDAP tree where your groups are.", order: 6)]
[ConfigurationRecord("Synchronize groups", "Enable or disabled groups synchronization", order: 6)]
public bool IsGroupSyncEnabled { get; set; } = false;
[ConfigurationRecord("Groups DN", "Full DN of LDAP tree where your groups are.", order: 7, "IsGroupSyncEnabled=true")]
public string GroupsDN { get; set; }
[ConfigurationRecord("Group object classes", "All values of LDAP objectClass attribute for groups in LDAP, divided by commas.", order: 7)]
[ConfigurationRecord("Group object classes", "All values of LDAP objectClass attribute for groups in LDAP, divided by commas.", order: 8, "IsGroupSyncEnabled=true")]
public string GroupObjectClasses { get; set; } = "posixGroup";
[ConfigurationRecord("Membership Group LDAP Attribute.", "It is the name of the LDAP Attribute on the group, which is used for membership mappings, for example memberUid", order: 8)]
[ConfigurationRecord("Membership Group LDAP Attribute.", "It is the name of the LDAP Attribute on the group, which is used for membership mappings, for example memberUid", order: 9, "IsGroupSyncEnabled=true")]
public string MembershipLDAPAttribute { get; set; }
[ConfigurationRecord("Membership User LDAP Attribute.", "It is the name of the LDAP Attribute on the user, which is used for membership mappings, for example uidNumber", order: 9)]
[ConfigurationRecord("Membership User LDAP Attribute.", "It is the name of the LDAP Attribute on the user, which is used for membership mappings, for example uidNumber", order: 10, "IsGroupSyncEnabled=true")]
public string MembershipUserLDAPAttribute { get; set; }
[ConfigurationRecord("User Groups Retrieve Strategy", "Membership User LDAP Attribute.", order: 10)]
[ConfigurationRecord("User Groups Retrieve Strategy", "Membership User LDAP Attribute.", order: 11, "IsGroupSyncEnabled=true")]
public LoadingStrategies RetrievingStrategies { get; set; }
[ConfigurationRecord("Member of LDAP Attribute", "Specifies the name of the LDAP Attribute on the LDAP user which contains the groups, which the user is member of.", order: 11, "RetrievingStrategies=LOAD_FROM_USER_MEMBEROF_ATTRIBUTE")]
[ConfigurationRecord("Member of LDAP Attribute", "Specifies the name of the LDAP Attribute on the LDAP user which contains the groups, which the user is member of.", order: 12, "RetrievingStrategies=LOAD_FROM_USER_MEMBEROF_ATTRIBUTE && IsGroupSyncEnabled=true")]
public string MemberOfAttribute { get; set; }

#endregion

[ConfigurationRecord("User Identifier LDAP Attribute", "Name of the LDAP attribute, which is used as a unique object identifier for objects in LDAP, objectSID for Active Directory or uidNumber of Open Ldap", order: 12)]
[ConfigurationRecord("User Identifier LDAP Attribute", "Name of the LDAP attribute, which is used as a unique object identifier for objects in LDAP, objectSID for Active Directory or uidNumber of Open Ldap", order: 13)]
public string UserIdLDAPAttribute { get; set; }
[ConfigurationRecord("Group Identifier LDAP Attribute", "Name of the LDAP attribute, which is used as a unique object identifier for objects in LDAP, objectSID for Active Directory or gidNumber of Open Ldap", order: 13)]
[ConfigurationRecord("Group Identifier LDAP Attribute", "Name of the LDAP attribute, which is used as a unique object identifier for objects in LDAP, objectSID for Active Directory or gidNumber of Open Ldap", order: 14, "IsGroupSyncEnabled=true")]
public string GroupIdLDAPAttribute { get; set; }

[ConfigurationRecord("Modification Date Attribute", "Name of the LDAP Attribute, which is used as the modification date for objects in LDAP", order: 14)]
[ConfigurationRecord("Modification Date Attribute", "Name of the LDAP Attribute, which is used as the modification date for objects in LDAP", order: 15)]
public string ModificationDateAttribute { get; set; } = "modificationDate";
[ConfigurationRecord("Batch size", "Number of records", order: 15)]
[ConfigurationRecord("Batch size", "Number of records", order: 16)]
public int BatchSize { get; set; } = 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ private ExtractedResult Extract(SearchResultEntryCollection entries, LDAPReprese
Version = version
};
users.Add(user);
var userGroups = ResolveUserGroups(userId, entry, options, ldapConnection, definition);
groups.AddRange(userGroups);
user.GroupIds = userGroups.Select(g => g.Id).ToList();
if(options.IsGroupSyncEnabled)
{
var userGroups = ResolveUserGroups(userId, entry, options, ldapConnection, definition);
groups.AddRange(userGroups);
user.GroupIds = userGroups.Select(g => g.Id).ToList();
}
}

return new ExtractedResult { Users = users, Groups = groups };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Task<ConfigurationKeyPairValueRecord> Get(string key, CancellationToken c

public Task<List<ConfigurationKeyPairValueRecord>> GetAll(CancellationToken cancellationToken)
{
if (_dbContext.Database.GetPendingMigrations().Any()) return Task.FromResult(new List<ConfigurationKeyPairValueRecord>());
if (!_dbContext.Database.IsInMemory() && _dbContext.Database.GetPendingMigrations().Any()) return Task.FromResult(new List<ConfigurationKeyPairValueRecord>());
return _dbContext.ConfigurationKeyPairValueRecords.ToListAsync(cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
{
<div>
<div>
<RadzenCheckBox @bind-Value="@property.ValueBoolean" Name="Checkbox" />
<RadzenCheckBox @bind-Value="@property.ValueBoolean" Change="@((bool b) => Select(property, b))" Name="Checkbox" />
<RadzenLabel Text="@property.DisplayName" Component="Checkbox" Style="margin-left: 8px; vertical-align: middle;" />
</div>
<p class="text-muted">@property.Description</p>
Expand Down Expand Up @@ -190,11 +190,17 @@
Refresh();
}

private void Select(EditableProperty p, bool o)
{
p.Value = o.ToString();
Refresh();
}

private void Refresh()
{
var values = GetValues();
var configuration = configurationDefsState.Value.ConfigurationDefs.Single(c => c.Id == Name);
Properties = AllProperties.Where(p => DisplayConditionEvaluator.IsValid(values, p.DisplayCondition)).ToList();
Properties = AllProperties.Where(p => DisplayConditionEvaluator.IsLogicalOperationValid(values, p.DisplayCondition)).ToList();
}

private Dictionary<string, string> GetValues()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ private ExtractionUserResult ExtractUsersAndClaims(IdentityProvisioning idProvis
Id = extractedUser.RepresentationId,
Source = idProvisioning.Definition.Name,
IdentityProvisioningId = idProvisioning.Id,
UpdateDateTime = DateTime.UtcNow
UpdateDateTime = DateTime.UtcNow,
CreateDateTime = DateTime.UtcNow
};
if (!string.IsNullOrWhiteSpace(extractedUser.Values))
{
Expand Down

0 comments on commit 2c65b52

Please sign in to comment.