Skip to content

Commit

Permalink
Setup global authentication scheme to fix meysamhadeli#3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay-Dee committed Sep 4, 2024
1 parent 6145b5f commit 23e4882
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/BuildingBlocks/BuildingBlocks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.64.0" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="MagicOnion" Version="6.1.4" />
<PackageReference Include="MagicOnion.Abstractions" Version="6.1.4" />
<PackageReference Include="MagicOnion.Client" Version="6.1.4" />
Expand Down
10 changes: 8 additions & 2 deletions src/BuildingBlocks/Jwt/JwtExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BuildingBlocks.Utils;
using BuildingBlocks.Web;
using Duende.IdentityServer.Models;
using IdentityServer4.AccessTokenValidation;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.DependencyInjection;

Expand All @@ -12,7 +13,12 @@ public static IServiceCollection AddJwt(this IServiceCollection services)
{
var jwtOptions = services.GetOptions<JwtBearerOptions>("Jwt");

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
services.AddAuthentication(options =>
{
options.DefaultScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
options.DefaultAuthenticateScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme;
})
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options =>
{
options.Authority = jwtOptions.Authority;
Expand All @@ -32,4 +38,4 @@ public static IServiceCollection AddJwt(this IServiceCollection services)

return services;
}
}
}

0 comments on commit 23e4882

Please sign in to comment.