47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Tiku.Application.Security;
|
|
|
|
namespace Tiku.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[ApiExplorerSettings(IgnoreApi = true)]
|
|
[Route("api/system/security")]
|
|
public sealed class SecurityDiagnosticsController(
|
|
ICurrentUser currentUser,
|
|
ITenantContext currentTenant) : ControllerBase
|
|
{
|
|
[Authorize(Policy = TikuPolicies.AuthenticatedUser)]
|
|
[HttpGet("authenticated")]
|
|
[EndpointSummary("诊断已登录用户上下文")]
|
|
public ActionResult<object> Authenticated()
|
|
{
|
|
return Ok(new
|
|
{
|
|
currentUser.UserId,
|
|
currentUser.IsAuthenticated
|
|
});
|
|
}
|
|
|
|
[Authorize(Policy = TikuPolicies.CurrentTenantMember)]
|
|
[HttpGet("tenant-member")]
|
|
[EndpointSummary("诊断当前租户成员上下文")]
|
|
public ActionResult<object> TenantMember()
|
|
{
|
|
return Ok(new
|
|
{
|
|
currentTenant.TenantId
|
|
});
|
|
}
|
|
|
|
[Authorize(Policy = TikuPolicies.TenantAdmin)]
|
|
[HttpGet("tenant-admin")]
|
|
[EndpointSummary("诊断当前租户管理员上下文")]
|
|
public ActionResult<object> TenantAdmin()
|
|
{
|
|
return Ok(new
|
|
{
|
|
currentTenant.TenantId
|
|
});
|
|
}
|
|
} |