Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1f1b103
Adding new item to organization license
cd-bitwarden Oct 22, 2025
f2388e6
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Oct 22, 2025
763cc10
fixing whitespace issues
cd-bitwarden Oct 22, 2025
69b8586
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Oct 22, 2025
de5b797
fixing missing comment
cd-bitwarden Oct 22, 2025
7d4d0fd
Merge branch 'SM-1571-DisableSMAdsForUsers' of https://github.com/bitโ€ฆ
cd-bitwarden Oct 22, 2025
4e6b2de
fixing merge conflicts
cd-bitwarden Oct 22, 2025
3d51aac
merge fix
cd-bitwarden Oct 22, 2025
f319d7a
db merge fixes
cd-bitwarden Oct 22, 2025
9c5fce0
fix
cd-bitwarden Oct 22, 2025
7c930b7
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Oct 23, 2025
9baa22c
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Oct 23, 2025
7db2a84
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Oct 28, 2025
2bca8b1
Updating SM to Sm, and adding more view refreshes
cd-bitwarden Nov 6, 2025
363fa4f
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Nov 6, 2025
10b0465
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Nov 6, 2025
911be60
Merge branch 'SM-1571-DisableSMAdsForUsers' of https://github.com/bitโ€ฆ
cd-bitwarden Nov 6, 2025
036b2bd
Merge branch 'SM-1571-DisableSMAdsForUsers' of https://github.com/bitโ€ฆ
cd-bitwarden Nov 6, 2025
b8a14c9
fixing merge conflicts
cd-bitwarden Nov 6, 2025
17fad60
Redoing migration
cd-bitwarden Nov 26, 2025
fbf07ab
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Dec 3, 2025
654cbc8
Update OrganizationLicense.cs
cd-bitwarden Dec 3, 2025
3fe93b5
Update OrganizationLicense.cs
cd-bitwarden Dec 3, 2025
f9d62ae
fixes
cd-bitwarden Dec 3, 2025
cad1c93
fixes
cd-bitwarden Dec 3, 2025
fd46c91
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Dec 3, 2025
de81e4e
Merge branch 'SM-1571-DisableSMAdsForUsers' of https://github.com/bitโ€ฆ
cd-bitwarden Dec 3, 2025
eedd4c2
fixing db issues
cd-bitwarden Dec 3, 2025
e309d36
fix
cd-bitwarden Dec 3, 2025
6d8cc7f
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Dec 3, 2025
126ca9f
Merge branch 'main' into SM-1571-DisableSMAdsForUsers
cd-bitwarden Dec 4, 2025
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 @@ -473,6 +473,7 @@ private void UpdateOrganization(Organization organization, OrganizationEditModel
organization.UseOrganizationDomains = model.UseOrganizationDomains;
organization.UseAdminSponsoredFamilies = model.UseAdminSponsoredFamilies;
organization.UseAutomaticUserConfirmation = model.UseAutomaticUserConfirmation;
organization.UseDisableSmAdsForUsers = model.UseDisableSmAdsForUsers;
organization.UsePhishingBlocker = model.UsePhishingBlocker;

//secrets
Expand Down
4 changes: 4 additions & 0 deletions src/Admin/AdminConsole/Models/OrganizationEditModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public OrganizationEditModel(
MaxAutoscaleSmServiceAccounts = org.MaxAutoscaleSmServiceAccounts;
UseOrganizationDomains = org.UseOrganizationDomains;
UseAutomaticUserConfirmation = org.UseAutomaticUserConfirmation;
UseDisableSmAdsForUsers = org.UseDisableSmAdsForUsers;
UsePhishingBlocker = org.UsePhishingBlocker;

_plans = plans;
Expand Down Expand Up @@ -196,6 +197,8 @@ public OrganizationEditModel(
public int? MaxAutoscaleSmServiceAccounts { get; set; }
[Display(Name = "Use Organization Domains")]
public bool UseOrganizationDomains { get; set; }
[Display(Name = "Disable SM Ads For Users")]
public bool UseDisableSmAdsForUsers { get; set; }

[Display(Name = "Automatic User Confirmation")]
public bool UseAutomaticUserConfirmation { get; set; }
Expand Down Expand Up @@ -330,6 +333,7 @@ public Organization ToOrganization(Organization existingOrganization)
existingOrganization.SmServiceAccounts = SmServiceAccounts;
existingOrganization.MaxAutoscaleSmServiceAccounts = MaxAutoscaleSmServiceAccounts;
existingOrganization.UseOrganizationDomains = UseOrganizationDomains;
existingOrganization.UseDisableSmAdsForUsers = UseDisableSmAdsForUsers;
existingOrganization.UsePhishingBlocker = UsePhishingBlocker;
return existingOrganization;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@
<input type="checkbox" class="form-check-input" asp-for="UseSecretsManager" disabled='@(canEditPlan ? null : "disabled")'>
<label class="form-check-label" asp-for="UseSecretsManager"></label>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" asp-for="UseDisableSmAdsForUsers" disabled='@(canEditPlan ? null : "disabled")'>
<label class="form-check-label" asp-for="UseDisableSmAdsForUsers"></label>
</div>
</div>
<div class="col-2">
<h3>Access Intelligence</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public OrganizationResponseModel(
UseOrganizationDomains = organization.UseOrganizationDomains;
UseAdminSponsoredFamilies = organization.UseAdminSponsoredFamilies;
UseAutomaticUserConfirmation = organization.UseAutomaticUserConfirmation;
UseDisableSmAdsForUsers = organization.UseDisableSmAdsForUsers;
UsePhishingBlocker = organization.UsePhishingBlocker;
}

Expand Down Expand Up @@ -124,6 +125,7 @@ public OrganizationResponseModel(
public bool UseOrganizationDomains { get; set; }
public bool UseAdminSponsoredFamilies { get; set; }
public bool UseAutomaticUserConfirmation { get; set; }
public bool UseDisableSmAdsForUsers { get; set; }
public bool UsePhishingBlocker { get; set; }
}

Expand Down
6 changes: 6 additions & 0 deletions src/Core/AdminConsole/Entities/Organization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ public class Organization : ITableObject<Guid>, IStorableSubscriber, IRevisable
/// </summary>
public bool UseAutomaticUserConfirmation { get; set; }

/// <summary>
/// If set to true, disables Secrets Manager ads for users in the organization
/// </summary>
public bool UseDisableSmAdsForUsers { get; set; }

/// <summary>
/// If set to true, the organization has phishing protection enabled.
/// </summary>
Expand Down Expand Up @@ -338,6 +343,7 @@ public void UpdateFromLicense(OrganizationLicense license, IFeatureService featu
UseRiskInsights = license.UseRiskInsights;
UseOrganizationDomains = license.UseOrganizationDomains;
UseAdminSponsoredFamilies = license.UseAdminSponsoredFamilies;
UseDisableSmAdsForUsers = license.UseDisableSmAdsForUsers;
UseAutomaticUserConfirmation = license.UseAutomaticUserConfirmation;
UsePhishingBlocker = license.UsePhishingBlocker;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public OrganizationAbility(Organization organization)
UseOrganizationDomains = organization.UseOrganizationDomains;
UseAdminSponsoredFamilies = organization.UseAdminSponsoredFamilies;
UseAutomaticUserConfirmation = organization.UseAutomaticUserConfirmation;
UseDisableSmAdsForUsers = organization.UseDisableSmAdsForUsers;
UsePhishingBlocker = organization.UsePhishingBlocker;
}

Expand All @@ -52,5 +53,6 @@ public OrganizationAbility(Organization organization)
public bool UseOrganizationDomains { get; set; }
public bool UseAdminSponsoredFamilies { get; set; }
public bool UseAutomaticUserConfirmation { get; set; }
public bool UseDisableSmAdsForUsers { get; set; }
public bool UsePhishingBlocker { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public Organization ToOrganization()
Status = Status,
UseRiskInsights = UseRiskInsights,
UseAdminSponsoredFamilies = UseAdminSponsoredFamilies,
UseDisableSmAdsForUsers = UseDisableSmAdsForUsers,
UsePhishingBlocker = UsePhishingBlocker,
};
}
Expand Down
2 changes: 2 additions & 0 deletions src/Core/AdminConsole/Services/OrganizationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public static Organization Create(
UseAdminSponsoredFamilies =
claimsPrincipal.GetValue<bool>(OrganizationLicenseConstants.UseAdminSponsoredFamilies),
UseAutomaticUserConfirmation = claimsPrincipal.GetValue<bool>(OrganizationLicenseConstants.UseAutomaticUserConfirmation),
UseDisableSmAdsForUsers =
claimsPrincipal.GetValue<bool>(OrganizationLicenseConstants.UseDisableSmAdsForUsers),
UsePhishingBlocker = claimsPrincipal.GetValue<bool>(OrganizationLicenseConstants.UsePhishingBlocker),
};

Expand Down
1 change: 1 addition & 0 deletions src/Core/Billing/Licenses/LicenseConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static class OrganizationLicenseConstants
public const string UseAdminSponsoredFamilies = nameof(UseAdminSponsoredFamilies);
public const string UseOrganizationDomains = nameof(UseOrganizationDomains);
public const string UseAutomaticUserConfirmation = nameof(UseAutomaticUserConfirmation);
public const string UseDisableSmAdsForUsers = nameof(UseDisableSmAdsForUsers);
public const string UsePhishingBlocker = nameof(UsePhishingBlocker);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public Task<List<Claim>> GenerateClaims(Organization entity, LicenseContext lice
new(nameof(OrganizationLicenseConstants.UseAdminSponsoredFamilies), entity.UseAdminSponsoredFamilies.ToString()),
new(nameof(OrganizationLicenseConstants.UseOrganizationDomains), entity.UseOrganizationDomains.ToString()),
new(nameof(OrganizationLicenseConstants.UseAutomaticUserConfirmation), entity.UseAutomaticUserConfirmation.ToString()),
new(nameof(OrganizationLicenseConstants.UseDisableSmAdsForUsers), entity.UseDisableSmAdsForUsers.ToString()),
new(nameof(OrganizationLicenseConstants.UsePhishingBlocker), entity.UsePhishingBlocker.ToString()),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public OrganizationLicense(Organization org, SubscriptionInfo subscriptionInfo,
public bool UseOrganizationDomains { get; set; }
public bool UseAdminSponsoredFamilies { get; set; }
public bool UseAutomaticUserConfirmation { get; set; }
public bool UseDisableSmAdsForUsers { get; set; }
public string Hash { get; set; }
public string Signature { get; set; }
public string Token { get; set; }
Expand Down Expand Up @@ -230,6 +231,7 @@ public byte[] GetDataBytes(bool forHash = false)
!p.Name.Equals(nameof(UseAdminSponsoredFamilies)) &&
!p.Name.Equals(nameof(UseOrganizationDomains)) &&
!p.Name.Equals(nameof(UseAutomaticUserConfirmation)) &&
!p.Name.Equals(nameof(UseDisableSmAdsForUsers)) &&
!p.Name.Equals(nameof(UsePhishingBlocker)))
.OrderBy(p => p.Name)
.Select(p => $"{p.Name}:{Core.Utilities.CoreHelpers.FormatLicenseSignatureValue(p.GetValue(this, null))}")
Expand Down Expand Up @@ -425,6 +427,7 @@ public bool VerifyData(
var useAdminSponsoredFamilies = claimsPrincipal.GetValue<bool>(nameof(UseAdminSponsoredFamilies));
var useOrganizationDomains = claimsPrincipal.GetValue<bool>(nameof(UseOrganizationDomains));
var useAutomaticUserConfirmation = claimsPrincipal.GetValue<bool>(nameof(UseAutomaticUserConfirmation));
var useDisableSmAdsForUsers = claimsPrincipal.GetValue<bool>(nameof(UseDisableSmAdsForUsers));

var claimedPlanType = claimsPrincipal.GetValue<PlanType>(nameof(PlanType));

Expand Down Expand Up @@ -461,7 +464,8 @@ public bool VerifyData(
smServiceAccounts == organization.SmServiceAccounts &&
useAdminSponsoredFamilies == organization.UseAdminSponsoredFamilies &&
useOrganizationDomains == organization.UseOrganizationDomains &&
useAutomaticUserConfirmation == organization.UseAutomaticUserConfirmation;
useAutomaticUserConfirmation == organization.UseAutomaticUserConfirmation &&
useDisableSmAdsForUsers == organization.UseDisableSmAdsForUsers;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public async Task<ICollection<OrganizationAbility>> GetManyAbilitiesAsync()
UseOrganizationDomains = e.UseOrganizationDomains,
UseAdminSponsoredFamilies = e.UseAdminSponsoredFamilies,
UseAutomaticUserConfirmation = e.UseAutomaticUserConfirmation,
UseDisableSmAdsForUsers = e.UseDisableSmAdsForUsers,
UsePhishingBlocker = e.UsePhishingBlocker
}).ToListAsync();
}
Expand Down
3 changes: 3 additions & 0 deletions src/Sql/dbo/Stored Procedures/Organization_Create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CREATE PROCEDURE [dbo].[Organization_Create]
@UseAdminSponsoredFamilies BIT = 0,
@SyncSeats BIT = 0,
@UseAutomaticUserConfirmation BIT = 0,
@UseDisableSmAdsForUsers BIT = 0,
@UsePhishingBlocker BIT = 0
AS
BEGIN
Expand Down Expand Up @@ -128,6 +129,7 @@ BEGIN
[UseAdminSponsoredFamilies],
[SyncSeats],
[UseAutomaticUserConfirmation],
[UseDisableSmAdsForUsers],
[UsePhishingBlocker]
)
VALUES
Expand Down Expand Up @@ -193,6 +195,7 @@ BEGIN
@UseAdminSponsoredFamilies,
@SyncSeats,
@UseAutomaticUserConfirmation,
@UseDisableSmAdsForUsers,
@UsePhishingBlocker
);
END
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ BEGIN
[UseOrganizationDomains],
[UseAdminSponsoredFamilies],
[UseAutomaticUserConfirmation],
[UseDisableSmAdsForUsers],
[UsePhishingBlocker]
FROM
[dbo].[Organization]
Expand Down
2 changes: 2 additions & 0 deletions src/Sql/dbo/Stored Procedures/Organization_Update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CREATE PROCEDURE [dbo].[Organization_Update]
@UseAdminSponsoredFamilies BIT = 0,
@SyncSeats BIT = 0,
@UseAutomaticUserConfirmation BIT = 0,
@UseDisableSmAdsForUsers BIT = 0,
@UsePhishingBlocker BIT = 0
AS
BEGIN
Expand Down Expand Up @@ -128,6 +129,7 @@ BEGIN
[UseAdminSponsoredFamilies] = @UseAdminSponsoredFamilies,
[SyncSeats] = @SyncSeats,
[UseAutomaticUserConfirmation] = @UseAutomaticUserConfirmation,
[UseDisableSmAdsForUsers] = @UseDisableSmAdsForUsers,
[UsePhishingBlocker] = @UsePhishingBlocker
WHERE
[Id] = @Id;
Expand Down
1 change: 1 addition & 0 deletions src/Sql/dbo/Tables/Organization.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CREATE TABLE [dbo].[Organization] (
[UseAdminSponsoredFamilies] BIT NOT NULL CONSTRAINT [DF_Organization_UseAdminSponsoredFamilies] DEFAULT (0),
[SyncSeats] BIT NOT NULL CONSTRAINT [DF_Organization_SyncSeats] DEFAULT (0),
[UseAutomaticUserConfirmation] BIT NOT NULL CONSTRAINT [DF_Organization_UseAutomaticUserConfirmation] DEFAULT (0),
[UseDisableSmAdsForUsers] BIT NOT NULL CONSTRAINT [DF_Organization_UseDisableSmAdsForUsers] DEFAULT (0),
[MaxStorageGbIncreased] SMALLINT NULL,
[UsePhishingBlocker] BIT NOT NULL CONSTRAINT [DF_Organization_UsePhishingBlocker] DEFAULT (0),
CONSTRAINT [PK_Organization] PRIMARY KEY CLUSTERED ([Id] ASC)
Expand Down
19 changes: 19 additions & 0 deletions test/Core.Test/AdminConsole/Entities/OrganizationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,23 @@ public void GetTwoFactorProviders_SavedWithName_Success()
var host = Assert.Contains("Host", (IDictionary<string, object>)duo.MetaData);
Assert.Equal("Host_value", host);
}

[Fact]
public void UseDisableSmAdsForUsers_DefaultValue_IsFalse()
{
var organization = new Organization();

Assert.False(organization.UseDisableSmAdsForUsers);
}

[Fact]
public void UseDisableSmAdsForUsers_CanBeSetToTrue()
{
var organization = new Organization
{
UseDisableSmAdsForUsers = true
};

Assert.True(organization.UseDisableSmAdsForUsers);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ private static Organization CreateDeterministicOrganization()
AllowAdminAccessToAllCollectionItems = true,
UseOrganizationDomains = true,
UseAdminSponsoredFamilies = false,
UseDisableSmAdsForUsers = false,
UsePhishingBlocker = false,
};
}
Expand Down Expand Up @@ -260,4 +261,34 @@ private static ILicensingService CreateMockLicensingService()
.Returns([0x00, 0x01, 0x02, 0x03]); // Dummy signature for hash testing
return mockService;
}

/// <summary>
/// Verifies that UseDisableSmAdsForUsers claim is properly generated in the license Token
/// and that VerifyData correctly validates the claim.
/// </summary>
[Theory]
[BitAutoData(true)]
[BitAutoData(false)]
public void OrganizationLicense_UseDisableSmAdsForUsers_ClaimGenerationAndValidation(bool useDisableSmAdsForUsers, ClaimsPrincipal claimsPrincipal)
{
// Arrange
var organization = CreateDeterministicOrganization();
organization.UseDisableSmAdsForUsers = useDisableSmAdsForUsers;

var subscriptionInfo = CreateDeterministicSubscriptionInfo();
var installationId = new Guid("78900000-0000-0000-0000-000000000123");
var mockLicensingService = CreateMockLicensingService();

var license = new OrganizationLicense(organization, subscriptionInfo, installationId, mockLicensingService);
license.Expires = DateTime.MaxValue; // Prevent expiration during test

var globalSettings = Substitute.For<IGlobalSettings>();
globalSettings.Installation.Returns(new GlobalSettings.InstallationSettings
{
Id = installationId
});

// Act & Assert - Verify VerifyData passes with the UseDisableSmAdsForUsers value
Assert.True(license.VerifyData(organization, claimsPrincipal, globalSettings));
}
}
Loading
Loading