feat: add some fediverse authentication code
* create applications on instances * generate authorize URLs * exchange oauth code for token and user info (untested) * recreate mastodon app on authentication failure
This commit is contained in:
parent
a4ca0902a3
commit
0077a165b5
8 changed files with 497 additions and 0 deletions
|
@ -0,0 +1,25 @@
|
|||
using Foxnouns.Backend.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Foxnouns.Backend.Controllers.Authentication;
|
||||
|
||||
[Route("/api/internal/auth/fediverse")]
|
||||
public class FediverseAuthController(FediverseAuthService fediverseAuthService) : ApiControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
[ProducesResponseType<FediverseUrlResponse>(statusCode: StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetFediverseUrlAsync([FromQuery] string instance)
|
||||
{
|
||||
var url = await fediverseAuthService.GenerateAuthUrlAsync(instance);
|
||||
return Ok(new FediverseUrlResponse(url));
|
||||
}
|
||||
|
||||
public async Task<IActionResult> FediverseCallbackAsync([FromBody] CallbackRequest req)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public record CallbackRequest(string Instance, string Code);
|
||||
|
||||
private record FediverseUrlResponse(string Url);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue