Skip to content

Instantly share code, notes, and snippets.

@martyncoup
Created April 6, 2021 12:17
Show Gist options
  • Save martyncoup/2571f30376350084b8a51ce7017ec860 to your computer and use it in GitHub Desktop.
Save martyncoup/2571f30376350084b8a51ce7017ec860 to your computer and use it in GitHub Desktop.
Checks for group claims in the list of role access
// Get group role assignments
var groupClaims = context.Principal.Claims.Where(w => w.Type == "groups").Select(s => s.Value).ToList();
var groupRoles = dbContext.RoleMaps.Where(w => groupClaims.Contains(w.ObjectId)).Join(dbContext.Roles, map => map.RoleId,
role => role.Id, (map, role) => new { RoleName = role.Name }).ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment