mirror of
https://github.com/bitwarden/server.git
synced 2024-11-26 12:55:17 +01:00
[SM-504] Fix service account not accessing secrets (#2709)
This commit is contained in:
parent
7365ca0925
commit
9cddb769fa
@ -35,6 +35,7 @@ public class CurrentContext : ICurrentContext
|
||||
public virtual string ClientId { get; set; }
|
||||
public virtual Version ClientVersion { get; set; }
|
||||
public virtual ClientType ClientType { get; set; }
|
||||
public virtual Guid? ServiceAccountOrganizationId { get; set; }
|
||||
|
||||
public CurrentContext(IProviderUserRepository providerUserRepository)
|
||||
{
|
||||
@ -146,6 +147,11 @@ public class CurrentContext : ICurrentContext
|
||||
ClientType = c;
|
||||
}
|
||||
|
||||
if (ClientType == ClientType.ServiceAccount)
|
||||
{
|
||||
ServiceAccountOrganizationId = new Guid(GetClaimValue(claimsDict, Claims.Organization));
|
||||
}
|
||||
|
||||
DeviceIdentifier = GetClaimValue(claimsDict, Claims.Device);
|
||||
|
||||
Organizations = GetOrganizations(claimsDict, orgApi);
|
||||
@ -445,6 +451,11 @@ public class CurrentContext : ICurrentContext
|
||||
|
||||
public bool AccessSecretsManager(Guid orgId)
|
||||
{
|
||||
if (ServiceAccountOrganizationId.HasValue && ServiceAccountOrganizationId.Value == orgId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return Organizations?.Any(o => o.Id == orgId && o.AccessSecretsManager) ?? false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user