last ...
This commit is contained in:
@@ -18,6 +18,57 @@ namespace xIds.Controllers
|
||||
{
|
||||
public partial class ApplicationsController
|
||||
{
|
||||
/// <summary>
|
||||
/// Show Api Key ...
|
||||
/// </summary>
|
||||
/// <param name="apiKeyId"></param>
|
||||
/// <param name="applicationId"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[RequireXPowered]
|
||||
[Authorize(LocalApi.PolicyName)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpGet("{applicationId}/ApiKeys/{apiKeyId}/Show")]
|
||||
public async Task<ActionResult<string>> ShowApiKey(
|
||||
[FromRoute] Guid apiKeyId,
|
||||
[FromRoute] int applicationId,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (
|
||||
apiKeyId.IsDefaultGuid() ||
|
||||
!applicationId.IsValidIntId())
|
||||
{
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
var userInfo = await GetUserInfo();
|
||||
|
||||
//
|
||||
var result = await provider.ShowApiKey(
|
||||
userInfo: userInfo,
|
||||
apiKeyId: apiKeyId,
|
||||
applicationId: applicationId,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
|
||||
//
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
var result = GetExceptionActionResult(ex);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create Api Key ...
|
||||
/// </summary>
|
||||
@@ -28,7 +79,7 @@ namespace xIds.Controllers
|
||||
[RequireXPowered]
|
||||
[Authorize(LocalApi.PolicyName)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Applications/{applicationId}/ApiKeys/Create")]
|
||||
[HttpPost("{applicationId}/ApiKeys/Create")]
|
||||
public async Task<ActionResult<XApiKeyDto>> CreateApiKey(
|
||||
[FromRoute] int applicationId,
|
||||
[FromBody] XCreateApiKeyRequest request,
|
||||
@@ -116,7 +167,7 @@ namespace xIds.Controllers
|
||||
[RequireXPowered]
|
||||
[Authorize(LocalApi.PolicyName)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpDelete("Applications/{applicationId}/ApiKeys/{apiKeyId}")]
|
||||
[HttpDelete("{applicationId}/ApiKeys/{apiKeyId}")]
|
||||
public async Task<ActionResult<XApiKeyDto>> RemoveApiKey(
|
||||
[FromRoute] Guid apiKeyId,
|
||||
[FromRoute] int applicationId,
|
||||
@@ -181,7 +232,7 @@ namespace xIds.Controllers
|
||||
[RequireXPowered]
|
||||
[Authorize(LocalApi.PolicyName)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Applications/{applicationId}/ApiKeys/{apiKeyId}")]
|
||||
[HttpPost("{applicationId}/ApiKeys/{apiKeyId}")]
|
||||
public async Task<ActionResult<XApiKeyDto>> RotateApiKey(
|
||||
[FromRoute] Guid apiKeyId,
|
||||
[FromRoute] int applicationId,
|
||||
@@ -262,7 +313,7 @@ namespace xIds.Controllers
|
||||
[RequireXPowered]
|
||||
[Authorize(LocalApi.PolicyName)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Applications/{applicationId}/ApiKeys/{apiKeyId}/Revoke")]
|
||||
[HttpPost("{applicationId}/ApiKeys/{apiKeyId}/Revoke")]
|
||||
public async Task<ActionResult<bool>> RevokeApiKey(
|
||||
[FromRoute] Guid apiKeyId,
|
||||
[FromRoute] int applicationId,
|
||||
@@ -323,8 +374,8 @@ namespace xIds.Controllers
|
||||
/// <returns></returns>
|
||||
[RequireXPowered]
|
||||
[Authorize(LocalApi.PolicyName)]
|
||||
[HttpGet("{applicationId}/ApiKeys")]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Applications/{applicationId}/ApiKeys")]
|
||||
public async Task<ActionResult<IEnumerable<XApiKeyDto>>> GetApiKeys(
|
||||
[FromRoute] int applicationId,
|
||||
CancellationToken cancellationToken = default
|
||||
@@ -384,7 +435,7 @@ namespace xIds.Controllers
|
||||
[RequireXPowered]
|
||||
[Authorize(LocalApi.PolicyName)]
|
||||
[Authorize(Policy = XPolicies.EnabledUser)]
|
||||
[HttpPost("Applications/{applicationId}/ApiKeys/{apiKeyId}/Usages")]
|
||||
[HttpGet("{applicationId}/ApiKeys/{apiKeyId}/Usages")]
|
||||
public async Task<ActionResult<IEnumerable<XApiKeyUsageDto>>> GetApiKeyUsages(
|
||||
[FromRoute] Guid apiKeyId,
|
||||
[FromRoute] int applicationId,
|
||||
@@ -460,8 +511,8 @@ namespace xIds.Controllers
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[RequireXPowered]
|
||||
[HttpPost("ApiKeys/Validate")]
|
||||
[Authorize(LocalApi.PolicyName)]
|
||||
[HttpPost("Applications/ApiKeys/Validate")]
|
||||
public async Task<ActionResult<XApiKeyValidationResult>> ValidateApiKey(
|
||||
[FromBody] XApiKeyValidationRequest request,
|
||||
CancellationToken cancellationToken = default
|
||||
|
||||
Reference in New Issue
Block a user