- Add XApiKeyAccess Authorization Attribute ...
- Refactor XApiAccountEndpoint and Add Application Routes into it ... - Refactor IXIdentityProvider and XIdentityProvider and Add Support for Calling ApplicationController on xIds and Retrieve Responses of it ... - Add XBaseTestIdentity Controller and Add Support for Test ApiKey Based Authorization on it ...
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using IdentityModel;
|
||||
using System.Threading;
|
||||
using xCommons.Constants;
|
||||
using xCommons.Extensions;
|
||||
using xExceptions.Constants;
|
||||
using xIdentityModels.Models;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xIdentityModels.Constants;
|
||||
using System.Collections.Generic;
|
||||
using xIdentityService.Constants;
|
||||
using xIdentityService.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace xIdentityService.Attributes
|
||||
{
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Class | AttributeTargets.Method,
|
||||
AllowMultiple = false,
|
||||
Inherited = true
|
||||
)]
|
||||
public class XApiKeyAccessAttribute : AuthorizeAttribute, IAuthorizationFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// Optional allowed scopes. If empty, no scope enforcement.
|
||||
/// </summary>
|
||||
public XApiKeyScope[] Scopes { get; set; }
|
||||
|
||||
public XApiKeyAccessAttribute(
|
||||
XApiKeyScope[] scopes = null
|
||||
)
|
||||
{
|
||||
//
|
||||
if (!scopes.HasChild())
|
||||
{
|
||||
scopes = [XApiKeyScope.Read];
|
||||
}
|
||||
|
||||
//
|
||||
Scopes = scopes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authorization Filtering ...
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public void OnAuthorization(AuthorizationFilterContext context)
|
||||
{
|
||||
Task.FromResult(OnAuthorizationAsync(context));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle Authorization Filtering Using Tasks ...
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
private async Task OnAuthorizationAsync(
|
||||
AuthorizationFilterContext context,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
// Access HttpContext ...
|
||||
var http = context.HttpContext;
|
||||
var error = XException.NotAuthorized.ToXError();
|
||||
var apiKeyAuthentication = XAuthenticationScheme.XApiKey.GetStringValue();
|
||||
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Obtain the endpoint currently being executed
|
||||
var endpointFeature = http.Features.Get<IEndpointFeature>();
|
||||
var endpoint = endpointFeature?.Endpoint;
|
||||
if (endpoint.IsNull() ||
|
||||
endpointFeature.IsNull()
|
||||
)
|
||||
{
|
||||
//
|
||||
error.Message = "Endpoint not Accessible ...";
|
||||
context.Result = new UnauthorizedObjectResult(error);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Identity Provider Service from DI ...
|
||||
var identityService = http.RequestServices
|
||||
.GetService<IXIdentityProvider>();
|
||||
if (identityService.IsNull())
|
||||
{
|
||||
//
|
||||
error.Message = "Api Key Service not Registered ...";
|
||||
context.Result = new UnauthorizedObjectResult(error);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Checking Header ...
|
||||
var apiKeyHeader = XHeader.ApiKey.GetStringValue();
|
||||
if (!http.Request.Headers.ContainsKey(apiKeyHeader))
|
||||
{
|
||||
//
|
||||
error.Message = "ApiKey not Exists ...";
|
||||
context.Result = new UnauthorizedObjectResult(error);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract ApiKey from Header ...
|
||||
var apiKey = http.Request.Headers[apiKeyHeader].ToString();
|
||||
if (apiKey.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
error.Message = "ApiKey not Provided ...";
|
||||
context.Result = new UnauthorizedObjectResult(error);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Client IP ...
|
||||
var clientIP = http.Request.HttpContext.Connection.RemoteIpAddress?.ToString();
|
||||
var scopes =
|
||||
!Scopes.HasChild()
|
||||
? string.Empty
|
||||
: Scopes.ToListString();
|
||||
|
||||
//
|
||||
// Prepare Validation Request ...
|
||||
var validationRequest = new XApiKeyValidationRequest
|
||||
{
|
||||
ApiKey = apiKey,
|
||||
ClientIP = clientIP,
|
||||
RequiredScope = scopes
|
||||
};
|
||||
|
||||
//
|
||||
// Validating ApiKey ...
|
||||
var validationResponse = identityService.ValidateApiKey(
|
||||
request: validationRequest,
|
||||
cancellationToken: cancellationToken
|
||||
)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
if (validationResponse.Errors.HasChild())
|
||||
{
|
||||
//
|
||||
var message = validationResponse.Errors.ToListString(',');
|
||||
error.Message = message;
|
||||
context.Result = new UnauthorizedObjectResult(error);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Creating Claims ...
|
||||
var claims = new List<Claim> {
|
||||
//
|
||||
// Owner Identifier of API Key ...
|
||||
new(ClaimTypes.Name, validationResponse.OwnerId),
|
||||
new(JwtClaimTypes.Subject, validationResponse.OwnerId),
|
||||
//
|
||||
// Application Id ...
|
||||
new(XCustomClaims.ApplicationId, validationResponse.ApplicationId.ToString()),
|
||||
//
|
||||
// Authentication Type ...
|
||||
new(XCustomClaims.AuthType, apiKeyAuthentication),
|
||||
};
|
||||
|
||||
//
|
||||
// Add Scopes ...
|
||||
if (validationResponse.Scopes != null)
|
||||
{
|
||||
//
|
||||
foreach (var scope in validationResponse.Scopes)
|
||||
{
|
||||
claims.Add(new Claim(JwtClaimTypes.Scope, scope));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Create Principal and Ticket ...
|
||||
var identity = new ClaimsIdentity(claims, apiKeyAuthentication);
|
||||
var principal = new ClaimsPrincipal(identity);
|
||||
|
||||
//
|
||||
http.User = principal;
|
||||
}
|
||||
catch
|
||||
{
|
||||
//
|
||||
error.Message = "ApiKey authorization failed ...";
|
||||
context.Result = new UnauthorizedObjectResult(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,7 +221,7 @@ namespace xIdentityService.Constants
|
||||
[StringValue("Applications")]
|
||||
CreateApplication,
|
||||
|
||||
[StringValue("Applications")]
|
||||
[StringValue("Applications/{id}")]
|
||||
UpdateApplication,
|
||||
|
||||
[StringValue("Applications/{id}")]
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
using xCommons.Providers;
|
||||
using xCommons.Attributes;
|
||||
using xCommons.Configurations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using xIdentityModels.Constants;
|
||||
using xIdentityService.Interfaces;
|
||||
using xIdentityService.Attributes;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace xIdentityService.Controllers
|
||||
{
|
||||
public abstract class XBaseTestIdentityController : XBaseIdentityController
|
||||
{
|
||||
protected XBaseTestIdentityController(
|
||||
ILogger<XBaseTestIdentityController> logger,
|
||||
XAppConfiguration appConfiguration,
|
||||
IXIdentityProvider identityProvider,
|
||||
XValidationProvider validationProvider
|
||||
) : base(logger, appConfiguration, identityProvider, validationProvider)
|
||||
{ }
|
||||
|
||||
//
|
||||
#region ApiKey Actions ...
|
||||
/// <summary>
|
||||
/// a simple Hello for Accessing ApiKey Authorization ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[XApiKeyAccess]
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpGet("HiApiKeyAccess")]
|
||||
public ActionResult<string> HiApiKeyAccess()
|
||||
{
|
||||
//
|
||||
var result = $"Hi ApiKey Access, is Passed ...";
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Hello for Accessing ApiKey Read Access ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpGet("HiApiKeyReadAccess")]
|
||||
[XApiKeyAccess(Scopes = [XApiKeyScope.Read])]
|
||||
public ActionResult<string> HiApiKeyReadAccess()
|
||||
{
|
||||
//
|
||||
var result = $"Hi ApiKey Read Access, is Passed ...";
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Hello for Accessing ApiKey Write Access ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpGet("HiApiKeyWriteAccess")]
|
||||
[XApiKeyAccess(scopes: [XApiKeyScope.Write])]
|
||||
public ActionResult<string> HiApiKeyWriteAccess()
|
||||
{
|
||||
//
|
||||
var result = $"Hi ApiKey Write Access, is Passed ...";
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Hello for Accessing ApiKey Manage Access ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpGet("HiApiKeyManageAccess")]
|
||||
[XApiKeyAccess(scopes: [XApiKeyScope.Manage])]
|
||||
public ActionResult<string> HiApiKManageAccess()
|
||||
{
|
||||
//
|
||||
var result = $"Hi ApiKey Manage Access, is Passed ...";
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// a simple Hello for Accessing ApiKey Admin Access ...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[RequireXPowered]
|
||||
[HttpGet("HiApiKeyAdminAccess")]
|
||||
[XApiKeyAccess(scopes: [XApiKeyScope.Admin])]
|
||||
public ActionResult<string> HiApiKeyAdminAccess()
|
||||
{
|
||||
//
|
||||
var result = $"Hi ApiKey Admin Access, is Passed ...";
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -369,11 +369,13 @@ namespace xIdentityService.Interfaces
|
||||
/// Update Specified Application ...
|
||||
/// </summary>
|
||||
/// <param name="tokens"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XApplicationDto> UpdateApplication(
|
||||
XTokenResponse tokens,
|
||||
int id,
|
||||
XApplicationDto item,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
@@ -461,11 +463,13 @@ namespace xIdentityService.Interfaces
|
||||
/// Update Specified ApiKey ...
|
||||
/// </summary>
|
||||
/// <param name="tokens"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XApiKeyDto> UpdateApiKey(
|
||||
XTokenResponse tokens,
|
||||
Guid id,
|
||||
XApiKeyDto item,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
@@ -540,11 +544,13 @@ namespace xIdentityService.Interfaces
|
||||
/// Update Specified Api Key Usage ...
|
||||
/// </summary>
|
||||
/// <param name="tokens"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
Task<XApiKeyUsageDto> UpdateApiKeyUsage(
|
||||
XTokenResponse tokens,
|
||||
long id,
|
||||
XApiKeyUsageDto item,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
@@ -7,16 +7,14 @@ using xExceptions.Constants;
|
||||
using System.Threading.Tasks;
|
||||
using xIdentityModels.Models;
|
||||
using xHttpService.Constants;
|
||||
using xHttpService.Extensions;
|
||||
using System.Collections.Generic;
|
||||
using xIdentityService.Constants;
|
||||
using xHttpService.Extensions;
|
||||
using MongoDB.Bson;
|
||||
|
||||
namespace xIdentityService.Providers
|
||||
{
|
||||
public partial class XIdentityProvider
|
||||
{
|
||||
|
||||
//
|
||||
#region Applications ...
|
||||
//
|
||||
@@ -65,11 +63,13 @@ namespace xIdentityService.Providers
|
||||
/// Update Specified Application ...
|
||||
/// </summary>
|
||||
/// <param name="tokens"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XApplicationDto> UpdateApplication(
|
||||
XTokenResponse tokens,
|
||||
int id,
|
||||
XApplicationDto item,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -84,12 +84,21 @@ namespace xIdentityService.Providers
|
||||
tokens.AccessToken
|
||||
)
|
||||
.ValidateGroupAsync();
|
||||
if (!id.IsValidIntId())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var client = GetRestClient(tokens);
|
||||
|
||||
//
|
||||
var request = GetRestRequet(XApiAccountEndpoint.UpdateApplication);
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.UpdateApplication,
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XId.GetStringValue (), id.ToString() }
|
||||
}
|
||||
);
|
||||
request.AddJsonBody(item);
|
||||
|
||||
//
|
||||
@@ -181,7 +190,7 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.GetApplication,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XId.GetStringValue (), id.ToString() }
|
||||
}
|
||||
);
|
||||
@@ -227,7 +236,7 @@ namespace xIdentityService.Providers
|
||||
|
||||
//
|
||||
// Attach XQuery to Request ...
|
||||
request = request.AttachXQuery (query);
|
||||
request = request.AttachXQuery(query);
|
||||
|
||||
//
|
||||
var response = await RunRestRequest<XQueryResult<XApplicationDto>>(
|
||||
@@ -307,7 +316,7 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.GetApiKey,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XId.GetStringValue (), id.ToString() }
|
||||
}
|
||||
);
|
||||
@@ -351,7 +360,7 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.RemoveApiKey,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XId.GetStringValue (), id.ToString() }
|
||||
}
|
||||
);
|
||||
@@ -369,11 +378,13 @@ namespace xIdentityService.Providers
|
||||
/// Update Specified ApiKey ...
|
||||
/// </summary>
|
||||
/// <param name="tokens"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XApiKeyDto> UpdateApiKey(
|
||||
XTokenResponse tokens,
|
||||
Guid id,
|
||||
XApiKeyDto item,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -382,12 +393,17 @@ namespace xIdentityService.Providers
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddIsGuid(id)
|
||||
.AddNotNull(item)
|
||||
.AddNotNull(tokens)
|
||||
.AddNotEmpty(
|
||||
tokens.AccessToken
|
||||
)
|
||||
.ValidateGroupAsync();
|
||||
if (id != item.Id)
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var client = GetRestClient(tokens);
|
||||
@@ -395,8 +411,8 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.UpdateApiKey,
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XId.GetStringValue (), item.Id.ToString() }
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XId.GetStringValue (), id.ToString() }
|
||||
}
|
||||
);
|
||||
request.AddJsonBody(item);
|
||||
@@ -442,7 +458,7 @@ namespace xIdentityService.Providers
|
||||
|
||||
//
|
||||
// Attach XQuery to Request ...
|
||||
request = request.AttachXQuery (query);
|
||||
request = request.AttachXQuery(query);
|
||||
|
||||
//
|
||||
var response = await RunRestRequest<XQueryResult<XApiKeyDto>>(
|
||||
@@ -565,7 +581,7 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.GetApiKeyUsage,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XId.GetStringValue (), id.ToString() }
|
||||
}
|
||||
);
|
||||
@@ -612,7 +628,7 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.RemoveApiKeyUsage,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XId.GetStringValue (), id.ToString() }
|
||||
}
|
||||
);
|
||||
@@ -630,11 +646,13 @@ namespace xIdentityService.Providers
|
||||
/// Update Specified Api Key Usage ...
|
||||
/// </summary>
|
||||
/// <param name="tokens"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<XApiKeyUsageDto> UpdateApiKeyUsage(
|
||||
XTokenResponse tokens,
|
||||
long id,
|
||||
XApiKeyUsageDto item,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -649,6 +667,9 @@ namespace xIdentityService.Providers
|
||||
tokens.AccessToken
|
||||
)
|
||||
.ValidateGroupAsync();
|
||||
if (id <= 0 || id != item.Id) {
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var client = GetRestClient(tokens);
|
||||
@@ -658,7 +679,7 @@ namespace xIdentityService.Providers
|
||||
XApiAccountEndpoint.UpdateApiKeyUsage,
|
||||
@params: new Dictionary<string, string>
|
||||
{
|
||||
{ XParam.XId.GetStringValue (), item.Id.ToString() }
|
||||
{ XParam.XId.GetStringValue (), id.ToString() }
|
||||
}
|
||||
);
|
||||
request.AddJsonBody(item);
|
||||
@@ -704,7 +725,7 @@ namespace xIdentityService.Providers
|
||||
|
||||
//
|
||||
// Attach XQuery to Request ...
|
||||
request = request.AttachXQuery (query);
|
||||
request = request.AttachXQuery(query);
|
||||
|
||||
//
|
||||
var response = await RunRestRequest<XQueryResult<XApiKeyUsageDto>>(
|
||||
@@ -790,7 +811,7 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.ShowApiKey,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XApiKeyId.GetStringValue (), apiKeyId.ToString() },
|
||||
{ XParam.XApplicationId.GetStringValue (), applicationId.ToString() }
|
||||
}
|
||||
@@ -841,9 +862,9 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.CreateApiKey,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XApplicationId.GetStringValue (), applicationId.ToString() }
|
||||
}
|
||||
}
|
||||
);
|
||||
request.AddJsonBody(createRequest);
|
||||
|
||||
@@ -891,8 +912,8 @@ namespace xIdentityService.Providers
|
||||
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.RemoveApiKey,
|
||||
@params: new Dictionary<string, string> {
|
||||
XApiAccountEndpoint.RemoveApiKeyCustom,
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XApiKeyId.GetStringValue (), apiKeyId.ToString() },
|
||||
{ XParam.XApplicationId.GetStringValue (), applicationId.ToString() }
|
||||
}
|
||||
@@ -945,7 +966,7 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.RotateApiKey,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XApiKeyId.GetStringValue (), apiKeyId.ToString() },
|
||||
{ XParam.XApplicationId.GetStringValue (), applicationId.ToString() }
|
||||
}
|
||||
@@ -997,7 +1018,7 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.RevokeApiKey,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XApiKeyId.GetStringValue (), apiKeyId.ToString() },
|
||||
{ XParam.XApplicationId.GetStringValue (), applicationId.ToString() }
|
||||
}
|
||||
@@ -1045,7 +1066,7 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.GetApiKeys,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XApplicationId.GetStringValue (), applicationId.ToString() }
|
||||
}
|
||||
);
|
||||
@@ -1095,7 +1116,7 @@ namespace xIdentityService.Providers
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.GetApiKeyUsages,
|
||||
@params: new Dictionary<string, string> {
|
||||
@params: new Dictionary<string, string> {
|
||||
{ XParam.XApiKeyId.GetStringValue (), apiKeyId.ToString() },
|
||||
{ XParam.XApplicationId.GetStringValue (), applicationId.ToString() }
|
||||
}
|
||||
@@ -1132,7 +1153,7 @@ namespace xIdentityService.Providers
|
||||
var client = GetRestClient();
|
||||
|
||||
//
|
||||
var checksum = SecurityProvider.Encrypt(validationRequest.ToJson()).ToMd5String();
|
||||
var checksum = SecurityProvider.Encrypt(validationRequest.ToJSON()).ToMd5String();
|
||||
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
@@ -1141,6 +1162,7 @@ namespace xIdentityService.Providers
|
||||
{ XHeader.ChecksumDigest.GetStringValue(), checksum }
|
||||
}
|
||||
);
|
||||
request.AddJsonBody(validationRequest);
|
||||
|
||||
//
|
||||
var response = await RunRestRequest<XApiKeyValidationResult>(
|
||||
|
||||
Reference in New Issue
Block a user