-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide members of confidential projects (#1031)
* Hide members of confidential projects Only the following people can see the list of members if a project is confidential: the manager(s) of the project, site admins, and the org admin(s) of the org(s) the project belongs to, if any. Everyone else, including people who are themselves members of the project, cannot see its membership. * Hide members list of confidential projects GQL query will return a users list consisting of only one entry, the project member currently viewing the page, if he's not allowed to see the other project members. * Change confidentiality default for project members For project members, and ONLY for project members, we will default to showing them for projects whose confidentiality has not been set. This isn't the most secure default, but it will avoid what would likely be a lot of user confusion. --------- Co-authored-by: Tim Haasdyk <tim_haasdyk@sil.org>
- Loading branch information
Showing
11 changed files
with
59 additions
and
51 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
backend/LexBoxApi/Auth/Requirements/AccessProjectUsersRequirementHandler.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
backend/LexBoxApi/GraphQL/CustomTypes/ProjectMembersVisibilityMiddleware.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using HotChocolate.Resolvers; | ||
using LexBoxApi.Auth; | ||
using LexCore.Entities; | ||
using LexCore.Exceptions; | ||
using LexCore.ServiceInterfaces; | ||
|
||
namespace LexBoxApi.GraphQL.CustomTypes; | ||
|
||
public class ProjectMembersVisibilityMiddleware(FieldDelegate next) | ||
{ | ||
public async Task InvokeAsync(IMiddlewareContext context, IPermissionService permissionService, LoggedInContext loggedInContext) | ||
{ | ||
await next(context); | ||
if (context.Result is IEnumerable<ProjectUsers> projectUsers) | ||
{ | ||
var contextProject = context.Parent<Project>(); | ||
var projId = contextProject?.Id ?? throw new RequiredException("Must include project ID in query if querying users"); | ||
if (!await permissionService.CanViewProjectMembers(projId)) | ||
{ | ||
// Confidential project, and user doesn't have permission to see its users, so only show the current user's membership | ||
context.Result = projectUsers.Where(pu => pu.User?.Id == loggedInContext.MaybeUser?.Id).ToList(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters