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:
parent
377c7925e2
commit
92d9b88afb
@ -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:
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user