Feature: Google and Facebook sign-in

This commit is contained in:
Kamigen
2024-06-05 16:01:44 -04:00
parent fc0c94306b
commit aa8a5ad93d
6 changed files with 96 additions and 34 deletions

View File

@@ -7,6 +7,7 @@ using Hutopy.Web;
using Azure.Identity;
using Hutopy.Infrastructure.Identity;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.Facebook;
using Microsoft.AspNetCore.Authentication.Google;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Identity;
@@ -56,7 +57,7 @@ builder.Services.AddWebServices();
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie()
.AddGoogle(
@@ -67,6 +68,17 @@ builder.Services.AddAuthentication(options =>
throw new ArgumentNullException("The Google ClientId is missing.");
options.ClientSecret = builder.Configuration["Google:ClientSecret"] ??
throw new ArgumentNullException("The Google ClientSecret is missing.");
//options.AccessDeniedPath = "/AccessDeniedPathInfo";
})
.AddFacebook(
FacebookDefaults.AuthenticationScheme,
options =>
{
options.ClientId = builder.Configuration["Facebook:ClientId"] ??
throw new ArgumentNullException("The Facebook ClientId is missing.");
options.ClientSecret = builder.Configuration["Facebook:ClientSecret"] ??
throw new ArgumentNullException("The Facebook ClientSecret is missing.");
//options.AccessDeniedPath = "/AccessDeniedPathInfo";
});
// Password hashing