Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Update authentication authority URL and add
Browse files Browse the repository at this point in the history
UserIdProvider
  • Loading branch information
Aloento committed Nov 26, 2023
1 parent 925c441 commit 03b559e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
15 changes: 15 additions & 0 deletions SoarCraft.AwaiShop/Helpers/UserIdProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace SoarCraft.AwaiShop.Helpers;

using Microsoft.AspNetCore.SignalR;
using Microsoft.Identity.Web;

/**
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 0.1.0
* </remarks>
*/
public class UserIdProvider : IUserIdProvider {
public string GetUserId(HubConnectionContext connection) => connection.User.GetObjectId()!;
}
6 changes: 5 additions & 1 deletion SoarCraft.AwaiShop/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using MessagePack;
using MessagePack.Resolvers;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using SoarCraft.AwaiShop;
using SoarCraft.AwaiShop.AdminHub;
using SoarCraft.AwaiShop.Helpers;
using SoarCraft.AwaiShop.Hub;

var builder = WebApplication.CreateBuilder(args);
Expand All @@ -12,7 +14,7 @@

builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, x => {
x.Authority = "https://SoarCraft.b2clogin.com/SoarCraft.onmicrosoft.com/B2C_1_RegLog/v2.0";
x.Authority = "https://login.microsoftonline.com/9ed42989-9bdb-439d-80e7-c709641d1f08/v2.0";
x.Audience = "0ac3ee82-159d-407c-8539-7a9e1e3a1989";
x.RequireHttpsMetadata = !Shared.Dev;
x.Events = new() {
Expand Down Expand Up @@ -47,6 +49,8 @@
.WithResolver(ContractlessStandardResolverAllowPrivate.Instance);
});

builder.Services.AddSingleton<IUserIdProvider, UserIdProvider>();

builder.Host.UseSystemd();

var app = builder.Build();
Expand Down
1 change: 1 addition & 0 deletions SoarCraft.AwaiShop/SoarCraft.AwaiShop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="2.15.5" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
</ItemGroup>

Expand Down

0 comments on commit 03b559e

Please sign in to comment.