1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-24 17:17:40 +01:00

current context for organization clients

This commit is contained in:
Kyle Spearrin 2019-03-01 17:30:59 -05:00
parent 8d51700120
commit 201f7d9aa4

View File

@ -25,6 +25,7 @@ namespace Bit.Core
public virtual string IpAddress { get; set; }
public virtual List<CurrentContentOrganization> Organizations { get; set; }
public virtual Guid? InstallationId { get; set; }
public virtual Guid? OrganizationId { get; set; }
public void Build(HttpContext httpContext, GlobalSettings globalSettings)
{
@ -73,11 +74,21 @@ namespace Bit.Core
var clientId = GetClaimValue(claimsDict, "client_id");
var clientSubject = GetClaimValue(claimsDict, "client_sub");
if((clientId?.StartsWith("installation.") ?? false) && clientSubject != null)
if(clientSubject != null)
{
if(Guid.TryParse(clientSubject, out var idGuid))
if(clientId?.StartsWith("installation.") ?? false)
{
InstallationId = idGuid;
if(Guid.TryParse(clientSubject, out var idGuid))
{
InstallationId = idGuid;
}
}
else if(clientId?.StartsWith("organization.") ?? false)
{
if(Guid.TryParse(clientSubject, out var idGuid))
{
OrganizationId = idGuid;
}
}
}