mirror of
https://github.com/bitwarden/server
synced 2026-01-09 12:03:21 +00:00
centralize AddIdentityAuthenticationServices
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.6.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System.Security.Claims;
|
||||
using Bit.Core;
|
||||
using Bit.Core.IdentityServer;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Utilities;
|
||||
using IdentityModel;
|
||||
using IdentityServer4.AccessTokenValidation;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
@@ -41,26 +37,7 @@ namespace Bit.Hub
|
||||
services.AddScoped<CurrentContext>();
|
||||
|
||||
// Identity
|
||||
services
|
||||
.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
|
||||
.AddIdentityServerAuthentication(options =>
|
||||
{
|
||||
options.Authority = globalSettings.BaseServiceUri.InternalIdentity;
|
||||
options.RequireHttpsMetadata = !Environment.IsDevelopment() &&
|
||||
globalSettings.BaseServiceUri.InternalIdentity.StartsWith("https");
|
||||
options.TokenRetriever = TokenRetrieval.FromAuthorizationHeaderOrQueryString();
|
||||
options.NameClaimType = ClaimTypes.Email;
|
||||
options.SupportedTokens = SupportedTokens.Jwt;
|
||||
});
|
||||
|
||||
services.AddAuthorization(config =>
|
||||
{
|
||||
config.AddPolicy("Application", policy =>
|
||||
{
|
||||
policy.RequireAuthenticatedUser();
|
||||
policy.RequireClaim(JwtClaimTypes.AuthenticationMethod, "Application");
|
||||
});
|
||||
});
|
||||
services.AddIdentityAuthenticationServices(globalSettings, Environment);
|
||||
|
||||
// SignalR
|
||||
services.AddSignalR();
|
||||
|
||||
Reference in New Issue
Block a user