Some checks failed
		
		
	
	Build Test Deploy / build-test (push) Has been cancelled
				
			Build Test Deploy / authority-container (push) Has been cancelled
				
			Build Test Deploy / docs (push) Has been cancelled
				
			Build Test Deploy / deploy (push) Has been cancelled
				
			Docs CI / lint-and-preview (push) Has been cancelled
				
			
		
			
				
	
	
		
			35 lines
		
	
	
		
			958 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			958 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Ablera.Serdica.Authorization.Models;
 | |
| using Microsoft.Extensions.Options;
 | |
| using System.Linq;
 | |
| 
 | |
| namespace Ablera.Serdica.Authorization;
 | |
| public class GroupsUtilities
 | |
| {
 | |
|     private readonly string[] KnownRoles;
 | |
| 
 | |
|     public GroupsUtilities(IOptions<RolesConfig> rolesOptions)
 | |
|     {
 | |
|         RolesConfig value = rolesOptions.Value;
 | |
|         if (value == null)
 | |
|         {
 | |
|             KnownRoles = new string[0];
 | |
|             return;
 | |
|         }
 | |
| 
 | |
|         KnownRoles = (from x in value.UserRoles.Concat(value.OperationsRoles).Concat(value.UnderwriterRoles).Concat(value.OrganizationAdminRoles)
 | |
|                 .Concat(value.SuperUserRoles)
 | |
|                       select x.ToUpper()).ToArray();
 | |
|     }
 | |
| 
 | |
|     public string[] GetGroupsByRole(string[] roles)
 | |
|     {
 | |
|         var source = KnownRoles.Intersect(roles);
 | |
|         if (!source.Any())
 | |
|         {
 | |
|             return new string[0];
 | |
|         }
 | |
| 
 | |
|         return source.ToArray();
 | |
|     }
 | |
| }
 |