mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 08:32:50 -05:00
[SM-380] Access checks for listing projects (#2496)
* Add project access checks for listing
This commit is contained in:
30
src/Core/Enums/AccessClientType.cs
Normal file
30
src/Core/Enums/AccessClientType.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Bit.Core.Identity;
|
||||
|
||||
namespace Bit.Core.Enums;
|
||||
|
||||
public enum AccessClientType
|
||||
{
|
||||
NoAccessCheck = -1,
|
||||
User = 0,
|
||||
Organization = 1,
|
||||
ServiceAccount = 2,
|
||||
}
|
||||
|
||||
public static class AccessClientHelper
|
||||
{
|
||||
public static AccessClientType ToAccessClient(ClientType clientType, bool bypassAccessCheck = false)
|
||||
{
|
||||
if (bypassAccessCheck)
|
||||
{
|
||||
return AccessClientType.NoAccessCheck;
|
||||
}
|
||||
|
||||
return clientType switch
|
||||
{
|
||||
ClientType.User => AccessClientType.User,
|
||||
ClientType.Organization => AccessClientType.Organization,
|
||||
ClientType.ServiceAccount => AccessClientType.ServiceAccount,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(clientType), clientType, null),
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user