Test: Integrated google auth

This commit is contained in:
Kamigen
2024-04-29 18:30:04 -04:00
parent be1d4cb3b6
commit 025195627c
9 changed files with 22 additions and 127 deletions

View File

@@ -6,6 +6,9 @@ using Hutopy.Infrastructure.Data;
using Hutopy.Infrastructure.Services;
using Hutopy.Web;
using Azure.Identity;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.Google;
using Microsoft.AspNetCore.Identity;
var builder = WebApplication.CreateBuilder(args);
@@ -48,8 +51,21 @@ builder.Services.AddApplicationServices();
builder.Services.AddInfrastructureServices(builder.Configuration);
builder.Services.AddWebServices();
// OAuth
builder.Services.AddAuthentication()
.AddGoogle(options =>
{
options.ClientId = builder.Configuration["Google:ClientId"] ?? throw new ArgumentNullException("The Google ClientId is missing.");
options.ClientSecret = builder.Configuration["Google:ClientSecret"] ?? throw new ArgumentNullException("The Google ClientSecret is missing.");
options.CallbackPath = "/api/google/o/signin-callback";
});
/*.AddFacebook(options =>
{
options.AppId = ""; // TODO
options.AppSecret = ""; // TODO
});*/ // We can add a lot more if needed, microsoft, twitter, etc.
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddScoped<IGoogleService, GoogleService>();
var app = builder.Build();