This commit is contained in:
2026-11-26 19:37:19 +03:30
parent 869a0476a0
commit 384cffac36
14 changed files with 882 additions and 6 deletions
+4 -1
View File
@@ -1,19 +1,22 @@
using xIds.Interfaces;
using xCommons.Providers;
using xCommons.Attributes;
using xIds.Controllers.Base;
using xCommons.Configurations;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authorization;
namespace xIds.Controllers
{
/// <summary>
/// Provide all available tools for manipulating users and accounts
/// </summary>
[Authorize]
[ApiController]
[RequireXPowered]
public partial class AccountController : XIBaseController
{
public AccountController(
IXIdentityManager identityManager,
ILogger<AccountController> logger,
+4
View File
@@ -1,17 +1,21 @@
using xIds.Interfaces;
using xCommons.Providers;
using xIds.Configurations;
using xCommons.Attributes;
using xIds.Controllers.Base;
using xCommons.Configurations;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authorization;
namespace xIds.Controllers
{
/// <summary>
/// Provide all available tools for manipulating users and accounts
/// </summary>
[Authorize]
[ApiController]
[RequireXPowered]
public partial class ApplicationsController : XIBaseController
{
private readonly IXApplicationProvider provider;
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace xIds.Controllers
{
public partial class AuthorizationController
{
}
}
@@ -0,0 +1,59 @@
using System;
using xIdentityHelper;
using System.Threading;
using xCommons.Extensions;
using xIdentityModels.Dtos;
using xExceptions.Constants;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
namespace xIds.Controllers
{
public partial class AuthorizationController
{
/// <summary>
/// Retrieve Specified Role By Id ...
/// </summary>
/// <param name="id"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
[HttpGet("Roles/{id}")]
[Authorize(Policy = XPolicies.EnabledAdmin)]
public virtual async Task<ActionResult<XRoleDefinitionDto>> Get(
[FromRoute] int id,
CancellationToken cancellationToken = default
)
{
//
try
{
//
// Validate ...
if (!id.IsValidIntId())
{
XException.InvalidArgs.Throw();
}
//
var userInfo = await GetUserInfo();
//
var result = await roleProvider.GetAsync(
id: id,
ignoreSoftDeleteds: true,
cancellationToken: cancellationToken
);
//
return Ok(result.ToDynamicObject());
}
catch (Exception ex)
{
//
var result = GetExceptionActionResult(ex);
return result;
}
}
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace xIds.Controllers
{
public partial class AuthorizationController
{
}
}
+38
View File
@@ -0,0 +1,38 @@
using xIds.Interfaces;
using xCommons.Providers;
using xCommons.Attributes;
using xIds.Controllers.Base;
using xCommons.Configurations;
using Microsoft.AspNetCore.Mvc;
using xIdentityService.Interfaces;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authorization;
namespace xIds.Controllers
{
[Authorize]
[ApiController]
[RequireXPowered]
public partial class AuthorizationController : XIBaseController
{
private readonly IXRoleProvider roleProvider;
private readonly IXScopeProvider scopeProvider;
private readonly IXPolicyProvider policyProvider;
public AuthorizationController(
IXRoleProvider roleProvider,
IXScopeProvider scopeProvider,
IXPolicyProvider policyProvider,
IXIdentityManager identityManager,
XAppConfiguration appConfiguration,
XValidationProvider validationProvider,
ILogger<AuthorizationController> logger
) : base(logger, appConfiguration, identityManager, validationProvider)
{
//
this.roleProvider = roleProvider;
this.scopeProvider = scopeProvider;
this.policyProvider = policyProvider;
}
}
}