Test: ASP Google login

This commit is contained in:
Kamigen
2024-05-01 17:54:21 -04:00
parent 025195627c
commit f9a661c8d2
3 changed files with 57 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Google;
namespace Hutopy.Web.Endpoints;
public class Google : EndpointGroupBase
{
public override void Map(WebApplication app)
{
app.MapGroup(this)
.MapGet("/o/sign-in", Callback);
}
private static async Task Callback(ISender sender, HttpContext context)
{
await context.ChallengeAsync(GoogleDefaults.AuthenticationScheme,
new AuthenticationProperties
{
RedirectUri = "/o/google/callback",
ExpiresUtc = DateTimeOffset.UtcNow.AddDays(30),
});
}
}