mirror of
https://github.com/bitwarden/server
synced 2025-12-15 07:43:54 +00:00
* Move account recovery logic to command (temporarily duplicated behind feature flag) * Move permission checks to authorization handler * Prevent user from recovering provider member account unless they are also provider member
60 lines
2.0 KiB
C#
60 lines
2.0 KiB
C#
using System.Reflection;
|
|
using AutoFixture;
|
|
using AutoFixture.Xunit2;
|
|
using Bit.Core.Context;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Models.Data;
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
|
|
namespace Bit.Core.Test.AdminConsole.AutoFixture;
|
|
|
|
public class CurrentContextOrganizationCustomization : ICustomization
|
|
{
|
|
public Guid Id { get; set; }
|
|
public OrganizationUserType Type { get; set; }
|
|
public Permissions Permissions { get; set; } = new();
|
|
public bool AccessSecretsManager { get; set; }
|
|
|
|
public void Customize(IFixture fixture)
|
|
{
|
|
fixture.Customize<CurrentContextOrganization>(composer => composer
|
|
.With(o => o.Id, Id)
|
|
.With(o => o.Type, Type)
|
|
.With(o => o.Permissions, Permissions)
|
|
.With(o => o.AccessSecretsManager, AccessSecretsManager));
|
|
}
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Method)]
|
|
public class CurrentContextOrganizationCustomizeAttribute : BitCustomizeAttribute
|
|
{
|
|
public Guid Id { get; set; }
|
|
public OrganizationUserType Type { get; set; } = OrganizationUserType.User;
|
|
public Permissions Permissions { get; set; } = new();
|
|
public bool AccessSecretsManager { get; set; } = false;
|
|
|
|
public override ICustomization GetCustomization() => new CurrentContextOrganizationCustomization()
|
|
{
|
|
Id = Id,
|
|
Type = Type,
|
|
Permissions = Permissions,
|
|
AccessSecretsManager = AccessSecretsManager
|
|
};
|
|
}
|
|
|
|
public class CurrentContextOrganizationAttribute : CustomizeAttribute
|
|
{
|
|
public Guid Id { get; set; }
|
|
public OrganizationUserType Type { get; set; } = OrganizationUserType.User;
|
|
public Permissions Permissions { get; set; } = new();
|
|
public bool AccessSecretsManager { get; set; } = false;
|
|
|
|
public override ICustomization GetCustomization(ParameterInfo _) => new CurrentContextOrganizationCustomization
|
|
{
|
|
Id = Id,
|
|
Type = Type,
|
|
Permissions = Permissions,
|
|
AccessSecretsManager = AccessSecretsManager
|
|
};
|
|
}
|