mirror of
https://github.com/bitwarden/server
synced 2026-01-07 11:03:37 +00:00
Revert filescoped (#2227)
* Revert "Add git blame entry (#2226)" This reverts commit239286737d. * Revert "Turn on file scoped namespaces (#2225)" This reverts commit34fb4cca2a.
This commit is contained in:
@@ -9,69 +9,70 @@ using IdentityServer4.ResponseHandling;
|
||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||
using Sustainsys.Saml2.AspNetCore2;
|
||||
|
||||
namespace Bit.Sso.Utilities;
|
||||
|
||||
public static class ServiceCollectionExtensions
|
||||
namespace Bit.Sso.Utilities
|
||||
{
|
||||
public static IServiceCollection AddSsoServices(this IServiceCollection services,
|
||||
GlobalSettings globalSettings)
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
// SAML SP Configuration
|
||||
var samlEnvironment = new SamlEnvironment
|
||||
public static IServiceCollection AddSsoServices(this IServiceCollection services,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
SpSigningCertificate = CoreHelpers.GetIdentityServerCertificate(globalSettings),
|
||||
};
|
||||
services.AddSingleton(s => samlEnvironment);
|
||||
|
||||
services.AddSingleton<Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider,
|
||||
DynamicAuthenticationSchemeProvider>();
|
||||
// Oidc
|
||||
services.AddSingleton<Microsoft.Extensions.Options.IPostConfigureOptions<OpenIdConnectOptions>,
|
||||
OpenIdConnectPostConfigureOptions>();
|
||||
services.AddSingleton<Microsoft.Extensions.Options.IOptionsMonitorCache<OpenIdConnectOptions>,
|
||||
ExtendedOptionsMonitorCache<OpenIdConnectOptions>>();
|
||||
// Saml2
|
||||
services.AddSingleton<Microsoft.Extensions.Options.IPostConfigureOptions<Saml2Options>,
|
||||
PostConfigureSaml2Options>();
|
||||
services.AddSingleton<Microsoft.Extensions.Options.IOptionsMonitorCache<Saml2Options>,
|
||||
ExtendedOptionsMonitorCache<Saml2Options>>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IIdentityServerBuilder AddSsoIdentityServerServices(this IServiceCollection services,
|
||||
IWebHostEnvironment env, GlobalSettings globalSettings)
|
||||
{
|
||||
services.AddTransient<IDiscoveryResponseGenerator, DiscoveryResponseGenerator>();
|
||||
|
||||
var issuerUri = new Uri(globalSettings.BaseServiceUri.InternalSso);
|
||||
var identityServerBuilder = services
|
||||
.AddIdentityServer(options =>
|
||||
// SAML SP Configuration
|
||||
var samlEnvironment = new SamlEnvironment
|
||||
{
|
||||
options.IssuerUri = $"{issuerUri.Scheme}://{issuerUri.Host}";
|
||||
if (env.IsDevelopment())
|
||||
SpSigningCertificate = CoreHelpers.GetIdentityServerCertificate(globalSettings),
|
||||
};
|
||||
services.AddSingleton(s => samlEnvironment);
|
||||
|
||||
services.AddSingleton<Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider,
|
||||
DynamicAuthenticationSchemeProvider>();
|
||||
// Oidc
|
||||
services.AddSingleton<Microsoft.Extensions.Options.IPostConfigureOptions<OpenIdConnectOptions>,
|
||||
OpenIdConnectPostConfigureOptions>();
|
||||
services.AddSingleton<Microsoft.Extensions.Options.IOptionsMonitorCache<OpenIdConnectOptions>,
|
||||
ExtendedOptionsMonitorCache<OpenIdConnectOptions>>();
|
||||
// Saml2
|
||||
services.AddSingleton<Microsoft.Extensions.Options.IPostConfigureOptions<Saml2Options>,
|
||||
PostConfigureSaml2Options>();
|
||||
services.AddSingleton<Microsoft.Extensions.Options.IOptionsMonitorCache<Saml2Options>,
|
||||
ExtendedOptionsMonitorCache<Saml2Options>>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IIdentityServerBuilder AddSsoIdentityServerServices(this IServiceCollection services,
|
||||
IWebHostEnvironment env, GlobalSettings globalSettings)
|
||||
{
|
||||
services.AddTransient<IDiscoveryResponseGenerator, DiscoveryResponseGenerator>();
|
||||
|
||||
var issuerUri = new Uri(globalSettings.BaseServiceUri.InternalSso);
|
||||
var identityServerBuilder = services
|
||||
.AddIdentityServer(options =>
|
||||
{
|
||||
options.Authentication.CookieSameSiteMode = Microsoft.AspNetCore.Http.SameSiteMode.Unspecified;
|
||||
}
|
||||
else
|
||||
options.IssuerUri = $"{issuerUri.Scheme}://{issuerUri.Host}";
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
options.Authentication.CookieSameSiteMode = Microsoft.AspNetCore.Http.SameSiteMode.Unspecified;
|
||||
}
|
||||
else
|
||||
{
|
||||
options.UserInteraction.ErrorUrl = "/Error";
|
||||
options.UserInteraction.ErrorIdParameter = "errorId";
|
||||
}
|
||||
options.InputLengthRestrictions.UserName = 256;
|
||||
})
|
||||
.AddInMemoryCaching()
|
||||
.AddInMemoryClients(new List<Client>
|
||||
{
|
||||
options.UserInteraction.ErrorUrl = "/Error";
|
||||
options.UserInteraction.ErrorIdParameter = "errorId";
|
||||
}
|
||||
options.InputLengthRestrictions.UserName = 256;
|
||||
})
|
||||
.AddInMemoryCaching()
|
||||
.AddInMemoryClients(new List<Client>
|
||||
{
|
||||
new OidcIdentityClient(globalSettings)
|
||||
})
|
||||
.AddInMemoryIdentityResources(new List<IdentityResource>
|
||||
{
|
||||
new IdentityResources.OpenId(),
|
||||
new IdentityResources.Profile()
|
||||
})
|
||||
.AddIdentityServerCertificate(env, globalSettings);
|
||||
new OidcIdentityClient(globalSettings)
|
||||
})
|
||||
.AddInMemoryIdentityResources(new List<IdentityResource>
|
||||
{
|
||||
new IdentityResources.OpenId(),
|
||||
new IdentityResources.Profile()
|
||||
})
|
||||
.AddIdentityServerCertificate(env, globalSettings);
|
||||
|
||||
return identityServerBuilder;
|
||||
return identityServerBuilder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user