Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Bit.Core.AdminConsole.Entities;
using OneOf;

namespace Bit.Core.Billing.Providers.Services.NoopImplementations;

/// <summary>
/// A no-op implementation of <see cref="IBusinessUnitConverter"/> for use in OSS (non-commercial) builds.
/// Business unit conversion is a commercial feature and is not available in OSS deployments.
/// All methods throw <see cref="NotSupportedException"/> to indicate the feature is unavailable.
/// </summary>
public class NoopBusinessUnitConverter : IBusinessUnitConverter
{
/// <inheritdoc />
/// <exception cref="NotSupportedException">
/// Always thrown because business unit conversion is not available in OSS builds.
/// </exception>
public Task<Guid> 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.");
}

/// <inheritdoc />
/// <exception cref="NotSupportedException">
/// Always thrown because business unit conversion is not available in OSS builds.
/// </exception>
public Task<OneOf<Guid, List<string>>> InitiateConversion(
Organization organization,
string providerAdminEmail)
{
throw new NotSupportedException(
"Business unit conversion is not available in non-commercial Bitwarden builds.");
}

/// <inheritdoc />
/// <exception cref="NotSupportedException">
/// Always thrown because business unit conversion is not available in OSS builds.
/// </exception>
public Task ResendConversionInvite(
Organization organization,
string providerAdminEmail)
{
throw new NotSupportedException(
"Business unit conversion is not available in non-commercial Bitwarden builds.");
}

/// <inheritdoc />
/// <exception cref="NotSupportedException">
/// Always thrown because business unit conversion is not available in OSS builds.
/// </exception>
public Task ResetConversion(
Organization organization,
string providerAdminEmail)
{
throw new NotSupportedException(
"Business unit conversion is not available in non-commercial Bitwarden builds.");
}
}
3 changes: 3 additions & 0 deletions src/SharedWeb/Utilities/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -366,6 +368,7 @@ public static void AddDefaultServices(this IServiceCollection services, GlobalSe
public static void AddOosServices(this IServiceCollection services)
{
services.AddScoped<IProviderService, NoopProviderService>();
services.AddTransient<IBusinessUnitConverter, NoopBusinessUnitConverter>();
services.AddScoped<IServiceAccountRepository, NoopServiceAccountRepository>();
services.AddScoped<ISecretRepository, NoopSecretRepository>();
services.AddScoped<ISecretVersionRepository, NoopSecretVersionRepository>();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<NotSupportedException>(
() => _sut.FinalizeConversion(
organization,
Guid.NewGuid(),
"token",
"providerKey",
"organizationKey"));
}

[Fact]
public async Task InitiateConversion_ThrowsNotSupportedException()
{
var organization = new Organization();

await Assert.ThrowsAsync<NotSupportedException>(
() => _sut.InitiateConversion(
organization,
"admin@example.com"));
}

[Fact]
public async Task ResendConversionInvite_ThrowsNotSupportedException()
{
var organization = new Organization();

await Assert.ThrowsAsync<NotSupportedException>(
() => _sut.ResendConversionInvite(
organization,
"admin@example.com"));
}

[Fact]
public async Task ResetConversion_ThrowsNotSupportedException()
{
var organization = new Organization();

await Assert.ThrowsAsync<NotSupportedException>(
() => _sut.ResetConversion(
organization,
"admin@example.com"));
}

[Fact]
public void ImplementsIBusinessUnitConverter()
{
Assert.IsAssignableFrom<IBusinessUnitConverter>(_sut);
}
}
Loading