mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
[PM-3569] Upgrade to Duende.Identity (#3185)
* Upgrade to Duende.Identity * Linting * Get rid of last IdentityServer4 package * Fix identity test since Duende returns additional configuration * Use Configure PostConfigure is ran after ASP.NET's PostConfigure so ConfigurationManager was already configured and our HttpHandler wasn't being respected. * Regenerate lockfiles * Move to 6.0.4 for patches * fixes with testing * Add additional grant type supported in 6.0.4 and beautify * Lockfile refresh * Reapply lockfiles * Apply change to new WebAuthn logic * When automated merging fails me --------- Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com> Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com>
This commit is contained in:
@ -33,10 +33,10 @@ using Bit.Core.Vault.Services;
|
||||
using Bit.Infrastructure.Dapper;
|
||||
using Bit.Infrastructure.EntityFramework;
|
||||
using DnsClient;
|
||||
using Duende.IdentityServer.Configuration;
|
||||
using IdentityModel;
|
||||
using IdentityServer4.AccessTokenValidation;
|
||||
using IdentityServer4.Configuration;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
@ -435,16 +435,24 @@ public static class ServiceCollectionExtensions
|
||||
this IServiceCollection services, GlobalSettings globalSettings, IWebHostEnvironment environment,
|
||||
Action<AuthorizationOptions> addAuthorization)
|
||||
{
|
||||
services
|
||||
.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
|
||||
.AddIdentityServerAuthentication(options =>
|
||||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(options =>
|
||||
{
|
||||
options.MapInboundClaims = false;
|
||||
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;
|
||||
options.TokenValidationParameters.ValidateAudience = false;
|
||||
options.TokenValidationParameters.ValidTypes = new[] { "at+jwt" };
|
||||
options.TokenValidationParameters.NameClaimType = ClaimTypes.Email;
|
||||
options.Events = new JwtBearerEvents
|
||||
{
|
||||
OnMessageReceived = (context) =>
|
||||
{
|
||||
context.Token = TokenRetrieval.FromAuthorizationHeaderOrQueryString()(context.Request);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
if (addAuthorization != null)
|
||||
|
Reference in New Issue
Block a user