- 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,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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user