1
0
mirror of https://github.com/bitwarden/server.git synced 2025-01-27 22:41:22 +01:00

Provide new feature flag context for devices (#5226)

This commit is contained in:
Matt Bishop 2025-01-08 13:54:34 -05:00 committed by GitHub
parent 377c7925e2
commit 92d9b88afb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -16,6 +16,7 @@ public class LaunchDarklyFeatureService : IFeatureService
private readonly ICurrentContext _currentContext;
private const string _anonymousUser = "25a15cac-58cf-4ac0-ad0f-b17c4bd92294";
private const string _contextKindDevice = "device";
private const string _contextKindOrganization = "organization";
private const string _contextKindServiceAccount = "service-account";
@ -158,6 +159,16 @@ public class LaunchDarklyFeatureService : IFeatureService
var builder = LaunchDarkly.Sdk.Context.MultiBuilder();
if (!string.IsNullOrWhiteSpace(_currentContext.DeviceIdentifier))
{
var ldDevice = LaunchDarkly.Sdk.Context.Builder(_currentContext.DeviceIdentifier);
ldDevice.Kind(_contextKindDevice);
SetCommonContextAttributes(ldDevice);
builder.Add(ldDevice.Build());
}
switch (_currentContext.IdentityClientType)
{
case IdentityClientType.User:

View File

@ -22,6 +22,7 @@ public class LaunchDarklyFeatureServiceTests
globalSettings.ProjectName = "LaunchDarkly Tests";
var currentContext = Substitute.For<ICurrentContext>();
currentContext.DeviceIdentifier.Returns(Guid.NewGuid().ToString());
currentContext.UserId.Returns(Guid.NewGuid());
currentContext.ClientVersion.Returns(new Version(AssemblyHelpers.GetVersion()));
currentContext.ClientVersionIsPrerelease.Returns(true);