Test: ASP Google login
This commit is contained in:
23
src/Web/Endpoints/Google.cs
Normal file
23
src/Web/Endpoints/Google.cs
Normal 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),
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user