You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
using Connected.Entities.Caching;
|
|
using Connected.Security.Identity;
|
|
|
|
namespace Common.Security.Identity;
|
|
|
|
internal interface IRoleCache : IEntityCacheClient<Role, int> { }
|
|
internal sealed class RoleCache : EntityCacheClient<Role, int>, IRoleCache
|
|
{
|
|
public RoleCache(IEntityCacheContext context) : base(context, Role.CacheKey)
|
|
{
|
|
}
|
|
|
|
protected override Task OnInitialized()
|
|
{
|
|
/*
|
|
* Register system or predefined roles. This roles cannot be changed. They differ
|
|
* from other roles in that they have a negative ids.
|
|
*/
|
|
|
|
/*
|
|
* Full control role. This role passed all authorization policies.
|
|
*/
|
|
Set(-1, new Role { Id = -1, Name = Roles.FullControl }, TimeSpan.Zero);
|
|
/*
|
|
* Implicit role assigned to every authenticated user.
|
|
*/
|
|
Set(-2, new Role { Id = -2, Name = Roles.Authenticated }, TimeSpan.Zero);
|
|
/*
|
|
* Implicit role assigned to non authenticated user.
|
|
*/
|
|
Set(-3, new Role { Id = -3, Name = Roles.Anonymous }, TimeSpan.Zero);
|
|
/*
|
|
* Implicit role assigned to every user
|
|
* regardless if it's authenticated or not.
|
|
*/
|
|
Set(-4, new Role { Id = -4, Name = Roles.Everyone }, TimeSpan.Zero);
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|