-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter users by group #243
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, I haven't study in details the tests and the logic itself :)
@@ -69,6 +69,13 @@ public interface IEntraIDProviderSettings | |||
/// Gets if only security-enabled groups should be returned | |||
/// </summary> | |||
bool FilterSecurityEnabledGroupsOnly { get; } | |||
|
|||
/// <summary> | |||
/// Comma separated list of group IDs (max 18 values). If set, users must be member of any of these groups to be returned to SharePoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any checks for that (max 18 groups)? I see that setter only assigns the value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in commit 368a5fe
public EntraIDEntityProvider(string claimsProviderName, IClaimsProviderSettings Settings) : base(claimsProviderName) | ||
{ | ||
this.Settings = Settings; | ||
|
||
// Reset cache if config changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And when config changes the new instance of EntraIDEntityProvider
is created, is that so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. This happens here:
this.EntityProvider = new EntraIDEntityProvider(Name, this.Settings); |
@@ -180,7 +190,7 @@ protected virtual void BuildFilter(OperationContext currentContext, List<EntraID | |||
|
|||
List<string> userFilterBuilder = new List<string>(); | |||
List<string> groupFilterBuilder = new List<string>(); | |||
List<string> userSelectBuilder = new List<string> { "UserType", "Mail" }; // UserType and Mail are always needed to deal with Guest users | |||
List<string> userSelectBuilder = new List<string> { "Id", "UserType", "Mail" }; // UserType and Mail are always needed to deal with Guest users |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And Id
was added because of the groups?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, basically, now I declare that I always want to get the user ID of each user returned by Graph
// List of groups that users must be member of, to be returned to SharePoint | ||
string[] groupsWhichUsersMustBeMemberOfRequestIds = null; | ||
string groupsWhichUsersMustBeMemberOfAny = this.Settings.GroupsWhichUsersMustBeMemberOfAny; | ||
//groupsWhichUsersMustBeMemberOfAny = "c9a94341-89b5-4109-a501-2a14027b5bf0"; // testEntraCPGroup_005 - everyone member |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should those comments be included in the master
branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may or may not keep them, they can could be useful as hints for debugging in the future
{ | ||
await cachedTenantData.WriteDataLock.WaitAsync().ConfigureAwait(false); | ||
lockToWriteInCachedDataWasTaken = true; | ||
if (cachedTenantData.UserIdsMembersOfAnyRequiredGroup != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You just checked in the line 468 that this is null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, here is the logic:
- Check if UserIdsMembersOfAnyRequiredGroup is null
- If so, wait for the lock, that is taken to fill UserIdsMembersOfAnyRequiredGroup
- Once lock is acquired, check if, in the meantime, UserIdsMembersOfAnyRequiredGroup was not already filled by another thread. If so, no need to fill it UserIdsMembersOfAnyRequiredGroup again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right.
@@ -352,7 +362,7 @@ protected async Task<List<DirectoryObject>> QueryEntraIDTenantsAsync(OperationCo | |||
return allResults; | |||
} | |||
|
|||
protected virtual async Task<List<DirectoryObject>> QueryEntraIDTenantAsync(OperationContext currentContext, EntraIDTenant tenant) | |||
protected virtual async Task<List<DirectoryObject>> QueryEntraIDTenantAsync(OperationContext currentContext, EntraIDTenant tenant, CachedEntraIDTenantData cachedTenantData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method could really use some refactoring into smaller ones :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you're right, but that would be for another day 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, definitely.
That'll be it for me, thank you for taking care of that feature :) |
* Update Yvand.EntraCP.Tests.csproj * Filter users by group (#243) * first implementation * add tests * improve tests * update tests * quick draft of caching authorized users for tests * rename objects * update caching * add property TenantDataCacheLifetimeInMinutes * validate the values set on the new properties * add debug info to track random error * Update CHANGELOG.md * Update UnitTestsHelper.cs * Update EntraIDProviderConfiguration.cs * Set scope correctly for national clouds (#246) * set scope correctly for national clouds * add comments * redesign management of national clouds * Update CHANGELOG.md * Update global config page to allow updating credentials of existing tenants (#248) * update page * Update GlobalSettings.ascx.cs * implement feature * Update CHANGELOG.md * Update CHANGELOG.md * Prompt user for confirmation before actually deleting a tenant * improve the tenant list view * Add controls in config page to set the groups list to restrict searchable users (#249) * add controls to ui * add plumbing * update logging * due to current design, minimum value for TenantDataCacheLifetimeInMinutes is 1 (not 0) * rename mêmbers related to the tenant cache * Bump all dependencies (#251) * bump all deps * Update CHANGELOG.md * Update EntraIDProviderConfiguration.cs * Update verify-prs-and-commits.yml * call reusable workflows using new project name "EntraCP" * make tenant name clickable to redirect to Entra portal
No description provided.