up
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

This commit is contained in:
root
2025-10-10 06:53:40 +00:00
parent 3aed135fb5
commit df5984d07e
1081 changed files with 97764 additions and 61389 deletions

View File

@@ -0,0 +1,34 @@
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();
}
}