last ...
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using xExceptions.Attributes;
|
||||
|
||||
namespace xIdentityModels.Constants
|
||||
{
|
||||
/// <summary>
|
||||
/// Kind of a Policy Definition ...
|
||||
/// </summary>
|
||||
public enum XPolicyKind
|
||||
{
|
||||
[StringValue("roleBased")]
|
||||
RoleBased = 0,
|
||||
|
||||
[StringValue("scopeBased")]
|
||||
ScopeBased = 1,
|
||||
|
||||
[StringValue("claimBased")]
|
||||
ClaimBased = 2,
|
||||
|
||||
[StringValue("composite")]
|
||||
Composite = 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using xModels.Base;
|
||||
using xIdentityModels.Constants;
|
||||
|
||||
namespace xIdentityModels.Dtos
|
||||
{
|
||||
/// <summary>
|
||||
/// a Policy Definition Model which can be converted to AuthorizationPolicy ...
|
||||
/// </summary>
|
||||
public class XPolicyDefinitionDto : XBaseIntIDEntityDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique Policy Name, e.g. enabledEditorPolicy ...
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Display Name ...
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Policy Kind ...
|
||||
/// </summary>
|
||||
public XPolicyKind Kind { get; set; } = XPolicyKind.RoleBased;
|
||||
|
||||
/// <summary>
|
||||
/// Comma Separated Role Names (explicit list) ...
|
||||
/// </summary>
|
||||
public string RequiredRoles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// if provided, all Roles with Weight >= MinRoleWeight will be Injected ...
|
||||
/// </summary>
|
||||
public int? MinRoleWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Comma Separated Scope Names ...
|
||||
/// </summary>
|
||||
public string RequiredScopes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Json Array of { "Type": "...", "Values": ["..."] } ...
|
||||
/// </summary>
|
||||
public string RequiredClaims { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Requires IsBanned=false and IsEnabled=true Claims ...
|
||||
/// </summary>
|
||||
public bool RequireEnabledUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Requires Authenticated User ...
|
||||
/// </summary>
|
||||
public bool RequireAuthenticatedUser { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Is Enabled ...
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Seeded from Constants, cannot be removed ...
|
||||
/// </summary>
|
||||
public bool IsSystem { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace xIdentityModels.Dtos
|
||||
{
|
||||
public class XPolicyEvaluationResultDto
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using xModels.Base;
|
||||
|
||||
namespace xIdentityModels.Dtos
|
||||
{
|
||||
/// <summary>
|
||||
/// a Role Definition Model (mirror of ASP.NET IdentityRole + Weight) ...
|
||||
/// </summary>
|
||||
public class XRoleDefinitionDto : XBaseIntIDEntityDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique Normalized Role Name, e.g. chief_clerk ...
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Persian Display Name, e.g. سر دبیر ...
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Role Weight, same as XUserRole enum (user=0 ... admin=10) ...
|
||||
/// </summary>
|
||||
public int Weight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional Parent Role for Inheritance ...
|
||||
/// </summary>
|
||||
public string ParentRoleName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is Enabled ...
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Seeded from Constants, cannot be removed ...
|
||||
/// </summary>
|
||||
public bool IsSystem { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using xModels.Base;
|
||||
|
||||
namespace xIdentityModels.Dtos
|
||||
{
|
||||
/// <summary>
|
||||
/// a Scope Definition Model (mirror of IdentityServer ApiScope) ...
|
||||
/// </summary>
|
||||
public class XScopeDefinitionDto : XBaseIntIDEntityDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique Scope Name, e.g. XAPI.read ...
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Display Name ...
|
||||
/// </summary>
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Description ...
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Comma Separated List of User Claims ...
|
||||
/// </summary>
|
||||
public string UserClaims { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional ApiResource Name on IdentityServer ...
|
||||
/// </summary>
|
||||
public string ApiResourceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is Enabled ...
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Seeded from Constants, cannot be removed ...
|
||||
/// </summary>
|
||||
public bool IsSystem { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -251,6 +251,198 @@ namespace xIdentityModels.Extensions
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Policy Kind ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsKindValid(this XPolicyDefinition source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault();
|
||||
switch (source.Kind)
|
||||
{
|
||||
//
|
||||
case Constants.XPolicyKind.Composite:
|
||||
//
|
||||
result =
|
||||
!(source.RequiredRoles.IsNullOrEmpty() &&
|
||||
source.RequiredClaims.IsNullOrEmpty() &&
|
||||
source.RequiredScopes.IsNullOrEmpty());
|
||||
break;
|
||||
|
||||
//
|
||||
case Constants.XPolicyKind.ClaimBased:
|
||||
//
|
||||
result =
|
||||
!source.RequiredClaims.IsNullOrEmpty();
|
||||
break;
|
||||
|
||||
//
|
||||
case Constants.XPolicyKind.ScopeBased:
|
||||
//
|
||||
result =
|
||||
!source.RequiredScopes.IsNullOrEmpty();
|
||||
break;
|
||||
|
||||
//
|
||||
case Constants.XPolicyKind.RoleBased:
|
||||
//
|
||||
result =
|
||||
!source.RequiredRoles.IsNullOrEmpty();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Policy Kind ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsKindValid(this XPolicyDefinitionDto source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault();
|
||||
switch (source.Kind)
|
||||
{
|
||||
//
|
||||
case Constants.XPolicyKind.Composite:
|
||||
//
|
||||
result =
|
||||
!(source.RequiredRoles.IsNullOrEmpty() &&
|
||||
source.RequiredClaims.IsNullOrEmpty() &&
|
||||
source.RequiredScopes.IsNullOrEmpty());
|
||||
break;
|
||||
|
||||
//
|
||||
case Constants.XPolicyKind.ClaimBased:
|
||||
//
|
||||
result =
|
||||
!source.RequiredClaims.IsNullOrEmpty();
|
||||
break;
|
||||
|
||||
//
|
||||
case Constants.XPolicyKind.ScopeBased:
|
||||
//
|
||||
result =
|
||||
!source.RequiredScopes.IsNullOrEmpty();
|
||||
break;
|
||||
|
||||
//
|
||||
case Constants.XPolicyKind.RoleBased:
|
||||
//
|
||||
result =
|
||||
!source.RequiredRoles.IsNullOrEmpty();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Item for Add or Update ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValidForAdd(this XPolicyDefinition source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
source.IsKindValid() &&
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.Name.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Item for Add or Update ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValidForAdd(this XPolicyDefinitionDto source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
source.IsKindValid() &&
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.Name.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Item for Add or Update ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValidForAdd(this XRoleDefinition source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.Name.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Item for Add or Update ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValidForAdd(this XRoleDefinitionDto source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.Name.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Item for Add or Update ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValidForAdd(this XScopeDefinition source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.Name.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Item for Add or Update ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValidForAdd(this XScopeDefinitionDto source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.Name.IsNullOrEmpty();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate Item for Add or Update ...
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace xIdentityModels.Interfaces
|
||||
{
|
||||
public interface IXAuthorizationCache
|
||||
{
|
||||
void Clear();
|
||||
void RemovePolicy(string name);
|
||||
void SetPolicy(string name, AuthorizationPolicy policy);
|
||||
bool TryGetPolicy(string name, out AuthorizationPolicy policy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using xModels.Dtos;
|
||||
using System.Threading;
|
||||
using xIdentityModels.Dtos;
|
||||
using System.Threading.Tasks;
|
||||
using xIdentityModels.Models;
|
||||
using System.Linq.Expressions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace xIdentityModels.Interfaces
|
||||
{
|
||||
public interface IXPolicyProvider
|
||||
{
|
||||
//
|
||||
#region Readers ...
|
||||
/// <summary>
|
||||
/// retrieve whole items as queryable ...
|
||||
/// </summary>
|
||||
/// <param name="asNoTracking">a flag for Tracking behaviour</param>
|
||||
/// <param name="predicate">an Expression for Filter Items ...</param>
|
||||
/// <param name="orderBuilder">an Order Builder expression for Ordering Query ...</param>
|
||||
/// <returns></returns>
|
||||
IQueryable<XPolicyDefinition> AsQueryable(
|
||||
bool asNoTracking = true,
|
||||
Expression<Func<XPolicyDefinition, bool>> predicate = null,
|
||||
Func<IQueryable<XPolicyDefinition>, IOrderedQueryable<XPolicyDefinition>> orderBuilder = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve an Entity by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XPolicyDefinitionDto> GetAsync(
|
||||
int id,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve all exists Entities ...
|
||||
/// </summary>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="orderBuilder"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XPolicyDefinitionDto>> GetAllAsync(
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Func<IQueryable<XPolicyDefinition>, IOrderedQueryable<XPolicyDefinition>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// find an Entity by providing a Conditional Expression ...
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XPolicyDefinitionDto> FindOneAsync(
|
||||
Expression<Func<XPolicyDefinition, bool>> predicate,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// find a collection of Entities by proving a Conditional Expression ...
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="orderBuilder"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XPolicyDefinitionDto>> FindManyAsync(
|
||||
Expression<Func<XPolicyDefinition, bool>> predicate,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Func<IQueryable<XPolicyDefinition>, IOrderedQueryable<XPolicyDefinition>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Entities ...
|
||||
/// </summary>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> CountAsync(
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Entities Pages by providing page size ...
|
||||
/// </summary>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="totalItems"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> PagesCountAsync(
|
||||
int pageSize,
|
||||
int? totalItems = null,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Check an Entity exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExistsAsync(
|
||||
int id,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Query ...
|
||||
/// <summary>
|
||||
/// retrieve Entities based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="orderBuilder"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XQueryResult<XPolicyDefinitionDto>> QueryAsync(
|
||||
XQuery query,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Expression<Func<XPolicyDefinition, bool>> predicate = null,
|
||||
Func<IQueryable<XPolicyDefinition>, IOrderedQueryable<XPolicyDefinition>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add/Update/Remove ...
|
||||
/// <summary>
|
||||
/// add a new Entity ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XPolicyDefinitionDto> AddAsync(
|
||||
XPolicyDefinitionDto item,
|
||||
bool saveChanges = true,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update an Entity values ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XPolicyDefinitionDto> UpdateAsync(
|
||||
int id,
|
||||
XPolicyDefinitionDto item,
|
||||
bool saveChanges = true,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// remove an Entity by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="softDelete"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XPolicyDefinitionDto> RemoveAsync(
|
||||
int id,
|
||||
bool softDelete = true,
|
||||
bool saveChanges = true,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Custom ...
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Enrichers ...
|
||||
/// <summary>
|
||||
/// Enrich Item ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XPolicyDefinitionDto> EnrichAsync(
|
||||
XPolicyDefinition source,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Item ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XPolicyDefinitionDto> EnrichAsync(
|
||||
XPolicyDefinitionDto source,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Enrich a Collection of Items(s) ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XPolicyDefinitionDto>> EnrichRangeAsync(
|
||||
IEnumerable<XPolicyDefinition> sources,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Enrich a Collection of Items(s) ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XPolicyDefinitionDto>> EnrichRangeAsync(
|
||||
IEnumerable<XPolicyDefinitionDto> sources,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using xModels.Dtos;
|
||||
using System.Threading;
|
||||
using xIdentityModels.Dtos;
|
||||
using System.Threading.Tasks;
|
||||
using xIdentityModels.Models;
|
||||
using System.Linq.Expressions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace xIdentityModels.Interfaces
|
||||
{
|
||||
public interface IXRoleProvider
|
||||
{
|
||||
//
|
||||
#region Readers ...
|
||||
/// <summary>
|
||||
/// retrieve whole items as queryable ...
|
||||
/// </summary>
|
||||
/// <param name="asNoTracking">a flag for Tracking behaviour</param>
|
||||
/// <param name="predicate">an Expression for Filter Items ...</param>
|
||||
/// <param name="orderBuilder">an Order Builder expression for Ordering Query ...</param>
|
||||
/// <returns></returns>
|
||||
IQueryable<XRoleDefinition> AsQueryable(
|
||||
bool asNoTracking = true,
|
||||
Expression<Func<XRoleDefinition, bool>> predicate = null,
|
||||
Func<IQueryable<XRoleDefinition>, IOrderedQueryable<XRoleDefinition>> orderBuilder = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve an Entity by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XRoleDefinitionDto> GetAsync(
|
||||
int id,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve all exists Entities ...
|
||||
/// </summary>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="orderBuilder"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XRoleDefinitionDto>> GetAllAsync(
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Func<IQueryable<XRoleDefinition>, IOrderedQueryable<XRoleDefinition>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// find an Entity by providing a Conditional Expression ...
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XRoleDefinitionDto> FindOneAsync(
|
||||
Expression<Func<XRoleDefinition, bool>> predicate,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// find a collection of Entities by proving a Conditional Expression ...
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="orderBuilder"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XRoleDefinitionDto>> FindManyAsync(
|
||||
Expression<Func<XRoleDefinition, bool>> predicate,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Func<IQueryable<XRoleDefinition>, IOrderedQueryable<XRoleDefinition>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Entities ...
|
||||
/// </summary>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> CountAsync(
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Entities Pages by providing page size ...
|
||||
/// </summary>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="totalItems"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> PagesCountAsync(
|
||||
int pageSize,
|
||||
int? totalItems = null,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Check an Entity exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExistsAsync(
|
||||
int id,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Query ...
|
||||
/// <summary>
|
||||
/// retrieve Entities based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="orderBuilder"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XQueryResult<XRoleDefinitionDto>> QueryAsync(
|
||||
XQuery query,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Expression<Func<XRoleDefinition, bool>> predicate = null,
|
||||
Func<IQueryable<XRoleDefinition>, IOrderedQueryable<XRoleDefinition>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add/Update/Remove ...
|
||||
/// <summary>
|
||||
/// add a new Entity ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XRoleDefinitionDto> AddAsync(
|
||||
XRoleDefinitionDto item,
|
||||
bool saveChanges = true,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update an Entity values ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XRoleDefinitionDto> UpdateAsync(
|
||||
int id,
|
||||
XRoleDefinitionDto item,
|
||||
bool saveChanges = true,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// remove an Entity by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="softDelete"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XRoleDefinitionDto> RemoveAsync(
|
||||
int id,
|
||||
bool softDelete = true,
|
||||
bool saveChanges = true,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Custom ...
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Enrichers ...
|
||||
/// <summary>
|
||||
/// Enrich Item ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XRoleDefinitionDto> EnrichAsync(
|
||||
XRoleDefinition source,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Item ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XRoleDefinitionDto> EnrichAsync(
|
||||
XRoleDefinitionDto source,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Enrich a Collection of Items(s) ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XRoleDefinitionDto>> EnrichRangeAsync(
|
||||
IEnumerable<XRoleDefinition> sources,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Enrich a Collection of Items(s) ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XRoleDefinitionDto>> EnrichRangeAsync(
|
||||
IEnumerable<XRoleDefinitionDto> sources,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
using System;
|
||||
using xModels.Dtos;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using xIdentityModels.Dtos;
|
||||
using System.Threading.Tasks;
|
||||
using xIdentityModels.Models;
|
||||
using System.Linq.Expressions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace xIdentityModels.Interfaces
|
||||
{
|
||||
public interface IXScopeProvider
|
||||
{
|
||||
//
|
||||
#region Readers ...
|
||||
/// <summary>
|
||||
/// retrieve whole items as queryable ...
|
||||
/// </summary>
|
||||
/// <param name="asNoTracking">a flag for Tracking behaviour</param>
|
||||
/// <param name="predicate">an Expression for Filter Items ...</param>
|
||||
/// <param name="orderBuilder">an Order Builder expression for Ordering Query ...</param>
|
||||
/// <returns></returns>
|
||||
IQueryable<XScopeDefinition> AsQueryable(
|
||||
bool asNoTracking = true,
|
||||
Expression<Func<XScopeDefinition, bool>> predicate = null,
|
||||
Func<IQueryable<XScopeDefinition>, IOrderedQueryable<XScopeDefinition>> orderBuilder = null
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve an Entity by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XScopeDefinitionDto> GetAsync(
|
||||
int id,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// retrieve all exists Entities ...
|
||||
/// </summary>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="orderBuilder"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XScopeDefinitionDto>> GetAllAsync(
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Func<IQueryable<XScopeDefinition>, IOrderedQueryable<XScopeDefinition>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// find an Entity by providing a Conditional Expression ...
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XScopeDefinitionDto> FindOneAsync(
|
||||
Expression<Func<XScopeDefinition, bool>> predicate,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// find a collection of Entities by proving a Conditional Expression ...
|
||||
/// </summary>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="orderBuilder"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XScopeDefinitionDto>> FindManyAsync(
|
||||
Expression<Func<XScopeDefinition, bool>> predicate,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Func<IQueryable<XScopeDefinition>, IOrderedQueryable<XScopeDefinition>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Entities ...
|
||||
/// </summary>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> CountAsync(
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// count all exists Entities Pages by providing page size ...
|
||||
/// </summary>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="totalItems"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> PagesCountAsync(
|
||||
int pageSize,
|
||||
int? totalItems = null,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Check an Entity exists or not ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> IsExistsAsync(
|
||||
int id,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Query ...
|
||||
/// <summary>
|
||||
/// retrieve Entities based on XQuery Pagination structure ...
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="ignoreSoftDeleteds"></param>
|
||||
/// <param name="predicate"></param>
|
||||
/// <param name="orderBuilder"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XQueryResult<XScopeDefinitionDto>> QueryAsync(
|
||||
XQuery query,
|
||||
bool ignoreSoftDeleteds = true,
|
||||
Expression<Func<XScopeDefinition, bool>> predicate = null,
|
||||
Func<IQueryable<XScopeDefinition>, IOrderedQueryable<XScopeDefinition>> orderBuilder = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Add/Update/Remove ...
|
||||
/// <summary>
|
||||
/// add a new Entity ...
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XScopeDefinitionDto> AddAsync(
|
||||
XScopeDefinitionDto item,
|
||||
bool saveChanges = true,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Update an Entity values ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XScopeDefinitionDto> UpdateAsync(
|
||||
int id,
|
||||
XScopeDefinitionDto item,
|
||||
bool saveChanges = true,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// remove an Entity by it's Id ...
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="softDelete"></param>
|
||||
/// <param name="saveChanges"></param>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XScopeDefinitionDto> RemoveAsync(
|
||||
int id,
|
||||
bool softDelete = true,
|
||||
bool saveChanges = true,
|
||||
XUserClaimsInfoDto userInfo = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Custom ...
|
||||
#endregion
|
||||
|
||||
//
|
||||
#region Enrichers ...
|
||||
/// <summary>
|
||||
/// Enrich Item ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XScopeDefinitionDto> EnrichAsync(
|
||||
XScopeDefinition source,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Enrich Item ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XScopeDefinitionDto> EnrichAsync(
|
||||
XScopeDefinitionDto source,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Enrich a Collection of Items(s) ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XScopeDefinitionDto>> EnrichRangeAsync(
|
||||
IEnumerable<XScopeDefinition> sources,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Enrich a Collection of Items(s) ...
|
||||
/// </summary>
|
||||
/// <param name="sources"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<XScopeDefinitionDto>> EnrichRangeAsync(
|
||||
IEnumerable<XScopeDefinitionDto> sources,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using xModels.Base;
|
||||
using xIdentityModels.Constants;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace xIdentityModels.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// a Policy Definition Model which can be converted to AuthorizationPolicy ...
|
||||
/// </summary>
|
||||
public class XPolicyDefinition : XBaseIntIDEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique Policy Name, e.g. enabledEditorPolicy ...
|
||||
/// </summary>
|
||||
[Required]
|
||||
[StringLength(200)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Display Name ...
|
||||
/// </summary>
|
||||
[StringLength(255)]
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Policy Kind ...
|
||||
/// </summary>
|
||||
public XPolicyKind Kind { get; set; } = XPolicyKind.RoleBased;
|
||||
|
||||
/// <summary>
|
||||
/// Comma Separated Role Names (explicit list) ...
|
||||
/// </summary>
|
||||
public string RequiredRoles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// if provided, all Roles with Weight >= MinRoleWeight will be Injected ...
|
||||
/// </summary>
|
||||
public int? MinRoleWeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Comma Separated Scope Names ...
|
||||
/// </summary>
|
||||
public string RequiredScopes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Json Array of { "Type": "...", "Values": ["..."] } ...
|
||||
/// </summary>
|
||||
public string RequiredClaims { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Requires IsBanned=false and IsEnabled=true Claims ...
|
||||
/// </summary>
|
||||
public bool RequireEnabledUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Requires Authenticated User ...
|
||||
/// </summary>
|
||||
public bool RequireAuthenticatedUser { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Is Enabled ...
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Seeded from Constants, cannot be removed ...
|
||||
/// </summary>
|
||||
public bool IsSystem { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using xModels.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace xIdentityModels.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// a Role Definition Model (mirror of ASP.NET IdentityRole + Weight) ...
|
||||
/// </summary>
|
||||
public class XRoleDefinition : XBaseIntIDEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique Normalized Role Name, e.g. chief_clerk ...
|
||||
/// </summary>
|
||||
[Required]
|
||||
[StringLength(256)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Persian Display Name, e.g. سر دبیر ...
|
||||
/// </summary>
|
||||
[StringLength(255)]
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Role Weight, same as XUserRole enum (user=0 ... admin=10) ...
|
||||
/// </summary>
|
||||
public int Weight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional Parent Role for Inheritance ...
|
||||
/// </summary>
|
||||
[StringLength(256)]
|
||||
public string ParentRoleName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is Enabled ...
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Seeded from Constants, cannot be removed ...
|
||||
/// </summary>
|
||||
public bool IsSystem { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using xModels.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace xIdentityModels.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// a Scope Definition Model (mirror of IdentityServer ApiScope) ...
|
||||
/// </summary>
|
||||
public class XScopeDefinition : XBaseIntIDEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique Scope Name, e.g. XAPI.read ...
|
||||
/// </summary>
|
||||
[Required]
|
||||
[StringLength(200)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Display Name ...
|
||||
/// </summary>
|
||||
[StringLength(255)]
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Description ...
|
||||
/// </summary>
|
||||
[StringLength(1000)]
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Comma Separated List of User Claims ...
|
||||
/// </summary>
|
||||
public string UserClaims { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional ApiResource Name on IdentityServer ...
|
||||
/// </summary>
|
||||
[StringLength(200)]
|
||||
public string ApiResourceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is Enabled ...
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Seeded from Constants, cannot be removed ...
|
||||
/// </summary>
|
||||
public bool IsSystem { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user