last ...
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using xIds.Providers;
|
||||
using xIds.Interfaces;
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xIdentityService.Interfaces;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace xIds.Extensions
|
||||
@@ -25,5 +28,37 @@ namespace xIds.Extensions
|
||||
{
|
||||
source.AddScoped<IXIdentityMessageProvider, XIdentityMessageProvider>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register Authorization Provider ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
public static void AddXAuthorizationProvider(
|
||||
this IServiceCollection source
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Requirements ...
|
||||
var roles = source.GetRegisteredService<IXRoleProvider>();
|
||||
var scopes = source.GetRegisteredService<IXScopeProvider>();
|
||||
var policies = source.GetRegisteredService<IXPolicyProvider>();
|
||||
var cache = source.GetRegisteredService<IXAuthorizationCache>();
|
||||
var resolver = source.GetRegisteredService<IXRoleHierarchyResolver>();
|
||||
|
||||
//
|
||||
var isInvalid =
|
||||
roles.IsNull() ||
|
||||
cache.IsNull() ||
|
||||
scopes.IsNull() ||
|
||||
policies.IsNull() ||
|
||||
resolver.IsNull();
|
||||
if (isInvalid)
|
||||
{
|
||||
XException.InvalidConfiguration.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
source.AddScoped<IXAuthorizationProvider, XAuthorizationProvider>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user