60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
using xCommons.Extensions;
|
|
using System.Threading.Tasks;
|
|
using xIdentityService.Interfaces;
|
|
|
|
//
|
|
// TODO: Remove this to xIds ...
|
|
namespace xIdentityService.Providers
|
|
{
|
|
public partial class XAuthorizationProvider : IXAuthorizationProvider
|
|
{
|
|
//
|
|
private readonly IXRoleProvider roles;
|
|
private readonly IXScopeProvider scopes;
|
|
private readonly IXPolicyProvider policies;
|
|
private readonly IXRoleSyncService roleSync;
|
|
private readonly IXAuthorizationCache cache;
|
|
private readonly IXScopeSyncService scopeSync;
|
|
private readonly IXRoleHierarchyResolver resolver;
|
|
// private readonly IXEventServiceProvider eventService;
|
|
|
|
public XAuthorizationProvider(
|
|
IXRoleProvider roles,
|
|
IXScopeProvider scopes,
|
|
IXPolicyProvider policies,
|
|
IXRoleSyncService roleSync,
|
|
IXAuthorizationCache cache,
|
|
IXScopeSyncService scopeSync,
|
|
IXRoleHierarchyResolver resolver
|
|
)
|
|
{
|
|
//
|
|
this.roles = roles;
|
|
this.cache = cache;
|
|
this.scopes = scopes;
|
|
this.policies = policies;
|
|
this.roleSync = roleSync;
|
|
this.resolver = resolver;
|
|
this.scopeSync = scopeSync;
|
|
}
|
|
|
|
//
|
|
#region Commons ...
|
|
/// <summary>
|
|
/// Clear Local Cache and Notify other Instances ...
|
|
/// </summary>
|
|
public async Task InvalidateAsync(string policyName = null)
|
|
{
|
|
//
|
|
if (policyName.IsNullOrEmpty())
|
|
{
|
|
cache.Clear();
|
|
}
|
|
else
|
|
{
|
|
cache.RemovePolicy(policyName);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |