This commit is contained in:
max
2025-05-05 16:00:18 +02:00
parent 05b95c6050
commit 46dbd8c6f5
4 changed files with 38 additions and 11 deletions

View File

@@ -1,33 +1,33 @@
using System.Security.Claims;
using System.Text.Json;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Mvc;
namespace DotBased.AspNet.Authority.Controllers;
[ApiController]
[Microsoft.AspNetCore.Mvc.Route("[controller]")]
[Route("[controller]")]
public class AuthorityController : ControllerBase
{
[Inject]
public IAuthenticationService AuthenticationService { get; set; }
[HttpGet("auth/login")]
[AllowAnonymous]
public async Task<ActionResult> LoginFromSchemeAsync([FromQuery(Name = "s")] string? scheme)
{
var authResult = await HttpContext.AuthenticateAsync();
var cPrincipal = new ClaimsPrincipal();
await HttpContext.SignInAsync(cPrincipal);
return Ok();
}
[HttpGet("auth/logout")]
public async Task<ActionResult> LogoutAsync()
{
await HttpContext.SignOutAsync();
return Ok();
}
[HttpGet("info")]
[AllowAnonymous]
public async Task<ActionResult<JsonDocument>> GetAuthorityInfoAsync()
{
return Ok();