diff --git a/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs b/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs index db574e71c536..7a26a37f0d09 100644 --- a/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs +++ b/bitwarden_license/src/Sso/Utilities/DynamicAuthenticationSchemeProvider.cs @@ -299,7 +299,7 @@ private DynamicAuthenticationScheme GetOidcAuthenticationScheme(string name, Sso ClientId = config.ClientId, ClientSecret = config.ClientSecret, ResponseType = "code", - ResponseMode = "form_post", + ResponseMode = "query", SignInScheme = AuthenticationSchemes.BitwardenExternalCookieAuthenticationScheme, SignOutScheme = IdentityServerConstants.SignoutScheme, SaveTokens = false, // reduce overall request size diff --git a/src/Core/Billing/Providers/Services/NoopImplementations/NoopBusinessUnitConverter.cs b/src/Core/Billing/Providers/Services/NoopImplementations/NoopBusinessUnitConverter.cs new file mode 100644 index 000000000000..65732f8a02c4 --- /dev/null +++ b/src/Core/Billing/Providers/Services/NoopImplementations/NoopBusinessUnitConverter.cs @@ -0,0 +1,63 @@ +using Bit.Core.AdminConsole.Entities; +using OneOf; + +namespace Bit.Core.Billing.Providers.Services.NoopImplementations; + +/// +/// A no-op implementation of for use in OSS (non-commercial) builds. +/// Business unit conversion is a commercial feature and is not available in OSS deployments. +/// All methods throw to indicate the feature is unavailable. +/// +public class NoopBusinessUnitConverter : IBusinessUnitConverter +{ + /// + /// + /// Always thrown because business unit conversion is not available in OSS builds. + /// + public Task FinalizeConversion( + Organization organization, + Guid userId, + string token, + string providerKey, + string organizationKey) + { + throw new NotSupportedException( + "Business unit conversion is not available in non-commercial Bitwarden builds."); + } + + /// + /// + /// Always thrown because business unit conversion is not available in OSS builds. + /// + public Task>> InitiateConversion( + Organization organization, + string providerAdminEmail) + { + throw new NotSupportedException( + "Business unit conversion is not available in non-commercial Bitwarden builds."); + } + + /// + /// + /// Always thrown because business unit conversion is not available in OSS builds. + /// + public Task ResendConversionInvite( + Organization organization, + string providerAdminEmail) + { + throw new NotSupportedException( + "Business unit conversion is not available in non-commercial Bitwarden builds."); + } + + /// + /// + /// Always thrown because business unit conversion is not available in OSS builds. + /// + public Task ResetConversion( + Organization organization, + string providerAdminEmail) + { + throw new NotSupportedException( + "Business unit conversion is not available in non-commercial Bitwarden builds."); + } +} diff --git a/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs b/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs index 8d65547f7621..1d8666de7eaf 100644 --- a/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs +++ b/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs @@ -23,6 +23,8 @@ using Bit.Core.Auth.UserFeatures; using Bit.Core.Auth.UserFeatures.EmergencyAccess; using Bit.Core.Auth.UserFeatures.PasswordValidation; +using Bit.Core.Billing.Providers.Services; +using Bit.Core.Billing.Providers.Services.NoopImplementations; using Bit.Core.Billing.Services; using Bit.Core.Billing.Services.Implementations; using Bit.Core.Billing.TrialInitiation; @@ -366,6 +368,7 @@ public static void AddDefaultServices(this IServiceCollection services, GlobalSe public static void AddOosServices(this IServiceCollection services) { services.AddScoped(); + services.AddTransient(); services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/test/Core.Test/Billing/Providers/Services/NoopImplementations/NoopBusinessUnitConverterTests.cs b/test/Core.Test/Billing/Providers/Services/NoopImplementations/NoopBusinessUnitConverterTests.cs new file mode 100644 index 000000000000..814d8a8ece33 --- /dev/null +++ b/test/Core.Test/Billing/Providers/Services/NoopImplementations/NoopBusinessUnitConverterTests.cs @@ -0,0 +1,63 @@ +using Bit.Core.AdminConsole.Entities; +using Bit.Core.Billing.Providers.Services.NoopImplementations; +using Xunit; + +namespace Bit.Core.Test.Billing.Providers.Services.NoopImplementations; + +public class NoopBusinessUnitConverterTests +{ + private readonly NoopBusinessUnitConverter _sut = new(); + + [Fact] + public async Task FinalizeConversion_ThrowsNotSupportedException() + { + var organization = new Organization(); + + await Assert.ThrowsAsync( + () => _sut.FinalizeConversion( + organization, + Guid.NewGuid(), + "token", + "providerKey", + "organizationKey")); + } + + [Fact] + public async Task InitiateConversion_ThrowsNotSupportedException() + { + var organization = new Organization(); + + await Assert.ThrowsAsync( + () => _sut.InitiateConversion( + organization, + "admin@example.com")); + } + + [Fact] + public async Task ResendConversionInvite_ThrowsNotSupportedException() + { + var organization = new Organization(); + + await Assert.ThrowsAsync( + () => _sut.ResendConversionInvite( + organization, + "admin@example.com")); + } + + [Fact] + public async Task ResetConversion_ThrowsNotSupportedException() + { + var organization = new Organization(); + + await Assert.ThrowsAsync( + () => _sut.ResetConversion( + organization, + "admin@example.com")); + } + + [Fact] + public void ImplementsIBusinessUnitConverter() + { + Assert.IsAssignableFrom(_sut); + } +}