[WIP]
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Text.Json;
|
||||
using DotBased.AspNet.Authority.Models.Data.System;
|
||||
using DotBased.AspNet.Authority.Services;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -9,7 +11,7 @@ namespace DotBased.AspNet.Authority.Controllers;
|
||||
[Route("[controller]")]
|
||||
public class AuthorityController(IAuthenticationService authenticationService) : ControllerBase
|
||||
{
|
||||
[HttpGet("auth/login")]
|
||||
[HttpGet(AuthorityDefaults.Paths.Login)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult> LoginFromSchemeAsync([FromQuery(Name = "s")] string? scheme, [FromQuery(Name = "ss")] string? sessionScheme)
|
||||
{
|
||||
@@ -17,17 +19,41 @@ public class AuthorityController(IAuthenticationService authenticationService) :
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpGet("auth/logout")]
|
||||
[HttpGet(AuthorityDefaults.Paths.Challenge)]
|
||||
[AllowAnonymous]
|
||||
public IActionResult ChallengeLogin([FromQuery(Name = "s")] string? scheme, [FromQuery(Name = "returnUrl")] string returnUrl = "/")
|
||||
{
|
||||
return Challenge(scheme, returnUrl);
|
||||
}
|
||||
|
||||
[HttpGet(AuthorityDefaults.Paths.Logout)]
|
||||
public async Task<ActionResult> LogoutAsync()
|
||||
{
|
||||
await HttpContext.SignOutAsync();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpGet("info")]
|
||||
[HttpGet(AuthorityDefaults.Paths.Info)]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<JsonDocument>> GetAuthorityInfoAsync()
|
||||
{
|
||||
return Ok();
|
||||
if (authenticationService is not AuthorityAuthenticationService authService)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
var schemesInfos = authService.GetAllSchemeInfos();
|
||||
|
||||
var info = new AuthorityInformation
|
||||
{
|
||||
IsAuthenticated = false,
|
||||
SchemeInformation = new SchemeInformation
|
||||
{
|
||||
DefaultScheme = authService.Options.DefaultScheme ?? "Unknown",
|
||||
AvailableSchemes = schemesInfos.ToList()
|
||||
}
|
||||
};
|
||||
|
||||
return Ok(info);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user