last ...
This commit is contained in:
@@ -15,6 +15,12 @@ namespace xIds.Controllers
|
|||||||
|
|
||||||
//
|
//
|
||||||
#region Open Actions ...
|
#region Open Actions ...
|
||||||
|
/// <summary>
|
||||||
|
/// Get Open Action ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
[HttpGet("Open")]
|
[HttpGet("Open")]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace xIds.Controllers
|
|||||||
//
|
//
|
||||||
#region Test Actions ...
|
#region Test Actions ...
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// API Read Scope
|
/// API Read Scope ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string message</returns>
|
/// <returns>string message</returns>
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
@@ -28,7 +28,7 @@ namespace xIds.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// API Write Scope
|
/// API Write Scope ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string message</returns>
|
/// <returns>string message</returns>
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
@@ -41,7 +41,7 @@ namespace xIds.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// API Admin Scope
|
/// API Admin Scope ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string message</returns>
|
/// <returns>string message</returns>
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
@@ -54,7 +54,7 @@ namespace xIds.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// API Manage Scop
|
/// API Manage Scop ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string message</returns>
|
/// <returns>string message</returns>
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
@@ -67,7 +67,7 @@ namespace xIds.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// a simple Action which returns a List of Authenticated User Claims
|
/// a simple Action which returns a List of Authenticated User Claims ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string message which represent current user's claims</returns>
|
/// <returns>string message which represent current user's claims</returns>
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
@@ -92,7 +92,7 @@ namespace xIds.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// a simple Hello User for Checking Authentication and Policy
|
/// a simple Hello User for Checking Authentication and Policy ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string message which contains authenticated user name</returns>
|
/// <returns>string message which contains authenticated user name</returns>
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
@@ -109,7 +109,7 @@ namespace xIds.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// a simple Hello User for Checking Authentication and Policy
|
/// a simple Hello User for Checking Authentication and Policy ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string message which contains authenticated user name</returns>
|
/// <returns>string message which contains authenticated user name</returns>
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
@@ -126,7 +126,7 @@ namespace xIds.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// a simple Hello User for Checking Authentication and Policy
|
/// a simple Hello User for Checking Authentication and Policy ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string message which contains authenticated user name</returns>
|
/// <returns>string message which contains authenticated user name</returns>
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
@@ -143,7 +143,7 @@ namespace xIds.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// a simple Hello User for Checking Authentication and Policy
|
/// a simple Hello User for Checking Authentication and Policy ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>string message which contains authenticated user name</returns>
|
/// <returns>string message which contains authenticated user name</returns>
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
@@ -159,11 +159,15 @@ namespace xIds.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// a simple Hello for Accessing ApiKey Authorization ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[XApiKeyAccess]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
[HttpGet("Test/HiApiKeyAccess")]
|
[HttpGet("Test/HiApiKeyAccess")]
|
||||||
[Authorize(LocalApi.PolicyName)]
|
[Authorize(LocalApi.PolicyName)]
|
||||||
[XApiKeyAccess(scopes: [XApiKeyScope.Manage])]
|
|
||||||
public ActionResult<string> HiApiKeyAccess()
|
public ActionResult<string> HiApiKeyAccess()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -173,11 +177,15 @@ namespace xIds.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// a simple Hello for Accessing ApiKey Read Access ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
[Authorize(LocalApi.PolicyName)]
|
[Authorize(LocalApi.PolicyName)]
|
||||||
[HttpGet("Test/HiApiKeyReadAccess")]
|
[HttpGet("Test/HiApiKeyReadAccess")]
|
||||||
[XApiKeyAccess(scopes: [XApiKeyScope.Read])]
|
[XApiKeyAccess(Scopes = [XApiKeyScope.Read])]
|
||||||
public ActionResult<string> HiApiKeyReadAccess()
|
public ActionResult<string> HiApiKeyReadAccess()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -187,6 +195,10 @@ namespace xIds.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// a simple Hello for Accessing ApiKey Write Access ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
[Authorize(LocalApi.PolicyName)]
|
[Authorize(LocalApi.PolicyName)]
|
||||||
@@ -201,6 +213,10 @@ namespace xIds.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// a simple Hello for Accessing ApiKey Manage Access ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
[Authorize(LocalApi.PolicyName)]
|
[Authorize(LocalApi.PolicyName)]
|
||||||
@@ -215,6 +231,10 @@ namespace xIds.Controllers
|
|||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// a simple Hello for Accessing ApiKey Admin Access ...
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[RequireXPowered]
|
[RequireXPowered]
|
||||||
[Authorize(LocalApi.PolicyName)]
|
[Authorize(LocalApi.PolicyName)]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using xModels.Dtos;
|
using xModels.Dtos;
|
||||||
using System.Threading;
|
|
||||||
using xIdentityHelper;
|
using xIdentityHelper;
|
||||||
|
using System.Threading;
|
||||||
using xCommons.Attributes;
|
using xCommons.Attributes;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xIdentityModels.Dtos;
|
using xIdentityModels.Dtos;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using IdentityModel;
|
using IdentityModel;
|
||||||
using xIds.Interfaces;
|
using xIds.Interfaces;
|
||||||
|
using System.Threading;
|
||||||
using xCommons.Constants;
|
using xCommons.Constants;
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xExceptions.Constants;
|
using xExceptions.Constants;
|
||||||
@@ -13,7 +14,6 @@ using xIdentityService.Constants;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace xIds.Providers
|
namespace xIds.Providers
|
||||||
{
|
{
|
||||||
@@ -36,7 +36,7 @@ namespace xIds.Providers
|
|||||||
//
|
//
|
||||||
if (!scopes.HasChild())
|
if (!scopes.HasChild())
|
||||||
{
|
{
|
||||||
scopes = [XApiKeyScope.Manage];
|
scopes = [XApiKeyScope.Read];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -84,7 +84,7 @@ namespace xIds.Providers
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
error.Message = "Api Key Service not Registered ...";
|
error.Message = "Api Key Service not Registered ...";
|
||||||
context.Result = new UnauthorizedObjectResult(error.ToJSON());
|
context.Result = new UnauthorizedObjectResult(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ namespace xIds.Providers
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
error.Message = "ApiKey not Exists ...";
|
error.Message = "ApiKey not Exists ...";
|
||||||
context.Result = new UnauthorizedObjectResult(error.ToJSON());
|
context.Result = new UnauthorizedObjectResult(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ namespace xIds.Providers
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
error.Message = "ApiKey not Provided ...";
|
error.Message = "ApiKey not Provided ...";
|
||||||
context.Result = new UnauthorizedObjectResult(error.ToJSON());
|
context.Result = new UnauthorizedObjectResult(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,9 +131,9 @@ namespace xIds.Providers
|
|||||||
if (validationResult.Errors.HasChild())
|
if (validationResult.Errors.HasChild())
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
var message = validationResult.Errors.ToListString('\n');
|
var message = validationResult.Errors.ToListString(',');
|
||||||
error.Message = message;
|
error.Message = message;
|
||||||
context.Result = new UnauthorizedObjectResult(error.ToJSON());
|
context.Result = new UnauthorizedObjectResult(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ namespace xIds.Providers
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
error.Message = "ApiKey authorization failed ...";
|
error.Message = "ApiKey authorization failed ...";
|
||||||
context.Result = new UnauthorizedObjectResult(error.ToJSON());
|
context.Result = new UnauthorizedObjectResult(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -512,13 +512,10 @@ namespace xIds.Providers
|
|||||||
var isIpValid =
|
var isIpValid =
|
||||||
!allowedIps.HasChild() ||
|
!allowedIps.HasChild() ||
|
||||||
allowedIps.Contains(clientIP);
|
allowedIps.Contains(clientIP);
|
||||||
var isScopeValid =
|
var isScopeValid =
|
||||||
!allowedScopes.HasChild() ||
|
allowedScopes
|
||||||
requiredScope.IsNullOrEmpty() ||
|
.IsScopePassed(requiredScopes);
|
||||||
requiredScopes
|
var isScopeIpValid =
|
||||||
.All(ts => allowedScopes
|
|
||||||
.Any(asc => asc.ToNormalString() == ts.ToNormalString()));
|
|
||||||
var isScopeIpValid =
|
|
||||||
isIpValid &&
|
isIpValid &&
|
||||||
isScopeValid
|
isScopeValid
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using xCommons.Extensions;
|
using xCommons.Extensions;
|
||||||
using xExceptions.Constants;
|
|
||||||
using xIdentityModels.Dtos;
|
using xIdentityModels.Dtos;
|
||||||
|
using xExceptions.Constants;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace xIds.Providers
|
namespace xIds.Providers
|
||||||
{
|
{
|
||||||
@@ -12,6 +12,11 @@ namespace xIds.Providers
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
#region OpenGet ...
|
#region OpenGet ...
|
||||||
|
/// <summary>
|
||||||
|
/// Get Open Action ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public async Task<XOpenActionInnerDto> OpenGet(
|
public async Task<XOpenActionInnerDto> OpenGet(
|
||||||
XOpenActionInnerDto model
|
XOpenActionInnerDto model
|
||||||
)
|
)
|
||||||
@@ -32,7 +37,12 @@ namespace xIds.Providers
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
/// <summary>
|
||||||
|
/// Get Open Action ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <param name="actionRequest"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public async Task<XOpenActionInnerDto> OpenGet(
|
public async Task<XOpenActionInnerDto> OpenGet(
|
||||||
string token,
|
string token,
|
||||||
string actionRequest
|
string actionRequest
|
||||||
@@ -119,6 +129,11 @@ namespace xIds.Providers
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get User Info For Open Actions ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public async Task<XOpenActionUserInfoDto> GetUserInfo(
|
public async Task<XOpenActionUserInfoDto> GetUserInfo(
|
||||||
XOpenActionRequestDto model
|
XOpenActionRequestDto model
|
||||||
)
|
)
|
||||||
@@ -147,6 +162,11 @@ namespace xIds.Providers
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve a Collection of Open Actions User Info by Providing Ids ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public async Task<IEnumerable<XOpenActionUserInfoDto>> GetUserInfos(
|
public async Task<IEnumerable<XOpenActionUserInfoDto>> GetUserInfos(
|
||||||
XOpenActionRequestDto model
|
XOpenActionRequestDto model
|
||||||
)
|
)
|
||||||
@@ -174,6 +194,12 @@ namespace xIds.Providers
|
|||||||
|
|
||||||
//
|
//
|
||||||
#region Private ...
|
#region Private ...
|
||||||
|
/// <summary>
|
||||||
|
/// Parse Models ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
private XOpenActionRequestDto ParseModel(
|
private XOpenActionRequestDto ParseModel(
|
||||||
string token,
|
string token,
|
||||||
string request
|
string request
|
||||||
|
|||||||
Reference in New Issue
Block a user