1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-25 17:27:45 +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 string IpAddress { get; set; }
public virtual List<CurrentContentOrganization> Organizations { get; set; } public virtual List<CurrentContentOrganization> Organizations { get; set; }
public virtual Guid? InstallationId { get; set; } public virtual Guid? InstallationId { get; set; }
public virtual Guid? OrganizationId { get; set; }
public void Build(HttpContext httpContext, GlobalSettings globalSettings) public void Build(HttpContext httpContext, GlobalSettings globalSettings)
{ {
@ -73,13 +74,23 @@ namespace Bit.Core
var clientId = GetClaimValue(claimsDict, "client_id"); var clientId = GetClaimValue(claimsDict, "client_id");
var clientSubject = GetClaimValue(claimsDict, "client_sub"); var clientSubject = GetClaimValue(claimsDict, "client_sub");
if((clientId?.StartsWith("installation.") ?? false) && clientSubject != null) if(clientSubject != null)
{
if(clientId?.StartsWith("installation.") ?? false)
{ {
if(Guid.TryParse(clientSubject, out var idGuid)) if(Guid.TryParse(clientSubject, out var idGuid))
{ {
InstallationId = idGuid; InstallationId = idGuid;
} }
} }
else if(clientId?.StartsWith("organization.") ?? false)
{
if(Guid.TryParse(clientSubject, out var idGuid))
{
OrganizationId = idGuid;
}
}
}
DeviceIdentifier = GetClaimValue(claimsDict, "device"); DeviceIdentifier = GetClaimValue(claimsDict, "device");