Skip to content

Commit

Permalink
Support admin only inherits from viewer role.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmohammed-goaco committed Oct 2, 2024
1 parent 704801e commit 84284d6
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ protected override async Task HandleRequirementAsync(AuthorizationHandlerContext
{
IUserInfoService _userInfo = serviceScope.ServiceProvider.GetRequiredService<IUserInfoService>();

var userScopes = await _userInfo.GetUserScopes();

// SupportAdmin role can do anything within any organisation
if (userScopes.Contains(PersonScopes.SupportAdmin))
{
context.Succeed(requirement);
return;
}

var organisationUserScopes = await _userInfo.GetOrganisationUserScopes();

// Admin role can do anything within this organisation
Expand All @@ -44,8 +35,11 @@ protected override async Task HandleRequirementAsync(AuthorizationHandlerContext
return;
}

// Editor role implies viewer permissions
if (requirement.Scope == OrganisationPersonScopes.Viewer && organisationUserScopes.Contains(OrganisationPersonScopes.Editor))
var userScopes = await _userInfo.GetUserScopes();

// Editor role and support admin both imply viewer permissions
if (requirement.Scope == OrganisationPersonScopes.Viewer &&
(organisationUserScopes.Contains(OrganisationPersonScopes.Editor) || userScopes.Contains(PersonScopes.SupportAdmin)))
{
context.Succeed(requirement);
return;
Expand Down

0 comments on commit 84284d6

Please sign in to comment.