private IReadOnlyDictionary <string, RoleCached> GetUserRoles(IRolesCache rolesCache) { if (!Identity.IsAuthenticated) { return(new Dictionary <string, RoleCached> { [RoleNames.Unregistered] = rolesCache.GetRole(RoleNames.Unregistered) }.ToImmutableDictionary()); } var roles = GetRolesNames(); var allGroups = rolesCache.AllRoles; var dictionaryBuilder = ImmutableDictionary.CreateBuilder <string, RoleCached>(); var registeredGroup = rolesCache.GetRole(RoleNames.Registered); dictionaryBuilder.Add(registeredGroup.Name, registeredGroup); foreach (var role in roles) { if (!allGroups.ContainsKey(role)) { continue; } var userGroup = allGroups[role]; dictionaryBuilder.Add(userGroup.Name, userGroup); } return(dictionaryBuilder.ToImmutable()); }
protected BaseController(IServiceProvider serviceProvider) { contentCache = serviceProvider.GetRequiredService <IContentCache>(); rolesCache = serviceProvider.GetRequiredService <IRolesCache>(); userManager = serviceProvider.GetRequiredService <SunUserManager>(); keyGenerator = serviceProvider.GetRequiredService <CacheKeyGenerator>(); }
public SectionClientCached(Section section, Dictionary <string, Type> clientComponentTypes, IRolesCache rolesCache) { Id = section.Id; Name = section.Name; Type = section.Type; if (section.Roles != null) { Roles = section.Roles.Split(',') .Select(x => rolesCache.GetRole(x)) .ToDictionary(x => x.Id, x => x) .ToImmutableDictionary(); } else { Roles = new Dictionary <int, RoleCached>().ToImmutableDictionary(); } if (clientComponentTypes.TryGetValue(Type, out Type type)) { object clientData = JsonSerializer.Deserialize(section.Options, type); string clientJson = JsonSerializer.Serialize(clientData); Options = SunJson.MakeJElement(clientJson); } }
public MenuCache( IDataBaseFactory dataBaseFactory, IRolesCache rolesCache) { this.dataBaseFactory = dataBaseFactory; this.rolesCache = rolesCache; }
public UserRolesAdminController( IUserRolesAdminPresenter userRolesAdminPresenter, JwtBlackListService jwtBlackListService, IRolesCache rolesCache, IServiceProvider serviceProvider) : base(serviceProvider) { this.userRolesAdminPresenter = userRolesAdminPresenter; this.jwtBlackListService = jwtBlackListService; }
public SectionsCache( IDataBaseFactory dataBaseFactory, IRolesCache rolesCache, SectionTypes sectionTypes) { this.rolesCache = rolesCache; this.dataBaseFactory = dataBaseFactory; this.sectionTypes = sectionTypes; Initialize(); }
public CategoriesPresenter(IRolesCache rolesCache, ICategoriesCache categoriesCache, IAuthorizationService authorizationService, OperationKeysContainer operationKeysContainer) { OperationKeys = operationKeysContainer; this.authorizationService = authorizationService; this.categoriesCache = categoriesCache; this.rolesCache = rolesCache; }
public JwtService( DataBaseConnection db, SunUserManager userManager, IRolesCache rolesCache, IOptions <JwtOptions> jwtOptions, ILoggerFactory loggerFactory) : base(db) { this.userManager = userManager; this.jwtOptions = jwtOptions.Value; logger = loggerFactory.CreateLogger <AccountController>(); this.rolesCache = rolesCache; }
public SunClaimsPrincipal(ClaimsPrincipal user, IRolesCache rolesCache, long sessionId = 0, string longToken2Db = null) : base(user) { this.SessionId = sessionId; this.LongToken2Db = longToken2Db; if (Identity.IsAuthenticated) { UserId = int.Parse(this.FindFirstValue(ClaimTypes.NameIdentifier)); } Roles = GetUserRoles(rolesCache); }
public CategoriesPresenter( IRolesCache rolesCache, ICategoriesCache categoriesCache, IOptionsMonitor <GlobalOptions> globalOptions, IAuthorizationService authorizationService, OperationKeysContainer operationKeysContainer) { OperationKeys = operationKeysContainer; this.authorizationService = authorizationService; this.categoriesCache = categoriesCache; this.rolesCache = rolesCache; this.globalOptions = globalOptions; }
public SunJweHandler( IOptionsMonitor <SunJweOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, IRolesCache rolesCache, JweService jweService, JweBlackListService jweBlackListService, SunUserManager userManager) : base(options, logger, encoder, clock) { this.rolesCache = rolesCache; this.jweService = jweService; this.userManager = userManager; this.jweBlackListService = jweBlackListService; }
public JweService( DataBaseConnection db, SunUserManager userManager, IRolesCache rolesCache, ICryptService cryptService, IOptionsMonitor <SecurityOptions> securityOptions, IOptionsMonitor <UrlPathsOptions> urlsOptions, ILoggerFactory loggerFactory) : base(db) { this.userManager = userManager; this.cryptService = cryptService; this.urlsOptions = urlsOptions; this.securityOptions = securityOptions; logger = loggerFactory.CreateLogger <AccountController>(); this.rolesCache = rolesCache; }
public JweService( DataBaseConnection db, SunUserManager userManager, IRolesCache rolesCache, ICryptService cryptService, IOptionsMonitor <JweOptions> jweOptions, IOptionsMonitor <GlobalOptions> globalOptions, ILoggerFactory loggerFactory) : base(db) { this.userManager = userManager; this.cryptService = cryptService; this.globalOptions = globalOptions; this.jweOptions = jweOptions; logger = loggerFactory.CreateLogger <AccountController>(); this.rolesCache = rolesCache; }
public SectionServerCached(Section section, Type serverSectionType, IRolesCache rolesCache) { Id = section.Id; Name = section.Name; IsCacheData = section.IsCacheData; if (section.Roles != null) { Roles = section.Roles.Split(',') .Select(x => rolesCache.GetRole(x)) .ToDictionary(x => x.Id, x => x) .ToImmutableDictionary(); } else { Roles = new Dictionary <int, RoleCached>().ToImmutableDictionary(); } Data = JsonSerializer.Deserialize(section.Options, serverSectionType); }
public ComponentsAdminManager( IRolesCache rolesCache, DataBaseConnection db) : base(db) { this.rolesCache = rolesCache; }
public ProfilePresenter(DataBaseConnection db, IRolesCache rolesCache) : base(db) { this.RolesCache = rolesCache; }
public ComponentsCache(IDataBaseFactory dataBaseFactory, IRolesCache rolesCache) { this.rolesCache = rolesCache; this.dataBaseFactory = dataBaseFactory; }
public MenuAdminManager(IRolesCache rolesCache, DataBaseConnection db) : base(db) { this.rolesCache = rolesCache; }
public SectionServerCached(Section section, Dictionary <string, Type> serverTypes, IRolesCache rolesCache) { Id = section.Id; Name = section.Name; IsCacheData = section.IsCacheData; if (section.Roles != null) { Roles = section.Roles.Split(',') .Select(x => rolesCache.GetRole(x)) .ToDictionary(x => x.Id, x => x) .ToImmutableDictionary(); } else { Roles = new Dictionary <int, RoleCached>().ToImmutableDictionary(); } if (!serverTypes.TryGetValue(section.Type, out Type type)) { throw new SunException("No component type found: " + section.Type); } Data = JsonSerializer.Deserialize(section.Options, type); }