mirror of
https://github.com/bitwarden/server
synced 2026-01-03 09:03:44 +00:00
[AC-1284] AC Team code ownership moves - Provider (#3359)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using Bit.Core.AdminConsole.Entities.Provider;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.AdminConsole.Repositories.Queries;
|
||||
|
||||
public class ProviderOrganizationCountByOrganizationIdsQuery : IQuery<ProviderOrganization>
|
||||
{
|
||||
private readonly IEnumerable<Guid> _organizationIds;
|
||||
|
||||
public ProviderOrganizationCountByOrganizationIdsQuery(IEnumerable<Guid> organizationIds)
|
||||
{
|
||||
_organizationIds = organizationIds;
|
||||
}
|
||||
|
||||
public IQueryable<ProviderOrganization> Run(DatabaseContext dbContext)
|
||||
{
|
||||
var query = from po in dbContext.ProviderOrganizations
|
||||
where _organizationIds.Contains(po.OrganizationId)
|
||||
select po;
|
||||
return query;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Bit.Core.AdminConsole.Models.Data.Provider;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.AdminConsole.Repositories.Queries;
|
||||
|
||||
public class ProviderOrganizationOrganizationDetailsReadByProviderIdQuery : IQuery<ProviderOrganizationOrganizationDetails>
|
||||
{
|
||||
private readonly Guid _providerId;
|
||||
public ProviderOrganizationOrganizationDetailsReadByProviderIdQuery(Guid providerId)
|
||||
{
|
||||
_providerId = providerId;
|
||||
}
|
||||
|
||||
public IQueryable<ProviderOrganizationOrganizationDetails> Run(DatabaseContext dbContext)
|
||||
{
|
||||
var query = from po in dbContext.ProviderOrganizations
|
||||
join o in dbContext.Organizations
|
||||
on po.OrganizationId equals o.Id
|
||||
join ou in dbContext.OrganizationUsers
|
||||
on po.OrganizationId equals ou.OrganizationId
|
||||
where po.ProviderId == _providerId
|
||||
select new { po, o };
|
||||
return query.Select(x => new ProviderOrganizationOrganizationDetails()
|
||||
{
|
||||
Id = x.po.Id,
|
||||
ProviderId = x.po.ProviderId,
|
||||
OrganizationId = x.po.OrganizationId,
|
||||
OrganizationName = x.o.Name,
|
||||
Key = x.po.Key,
|
||||
Settings = x.po.Settings,
|
||||
CreationDate = x.po.CreationDate,
|
||||
RevisionDate = x.po.RevisionDate,
|
||||
UserCount = x.o.OrganizationUsers.Count(ou => ou.Status == Core.Enums.OrganizationUserStatusType.Confirmed),
|
||||
Seats = x.o.Seats,
|
||||
Plan = x.o.Plan,
|
||||
Status = x.o.Status
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Bit.Core.AdminConsole.Models.Data.Provider;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.AdminConsole.Repositories.Queries;
|
||||
|
||||
public class ProviderOrganizationReadByUserIdQuery : IQuery<ProviderOrganizationProviderDetails>
|
||||
{
|
||||
private readonly Guid _userId;
|
||||
|
||||
public ProviderOrganizationReadByUserIdQuery(Guid userId)
|
||||
{
|
||||
_userId = userId;
|
||||
}
|
||||
|
||||
public IQueryable<ProviderOrganizationProviderDetails> Run(DatabaseContext dbContext)
|
||||
{
|
||||
var query = from po in dbContext.ProviderOrganizations
|
||||
join ou in dbContext.OrganizationUsers
|
||||
on po.OrganizationId equals ou.OrganizationId
|
||||
join p in dbContext.Providers
|
||||
on po.ProviderId equals p.Id
|
||||
where ou.UserId == _userId
|
||||
select new ProviderOrganizationProviderDetails
|
||||
{
|
||||
Id = po.Id,
|
||||
OrganizationId = po.OrganizationId,
|
||||
ProviderId = po.ProviderId,
|
||||
ProviderName = p.Name,
|
||||
ProviderType = p.Type
|
||||
};
|
||||
return query;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using Bit.Core.AdminConsole.Models.Data.Provider;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.AdminConsole.Repositories.Queries;
|
||||
|
||||
public class ProviderUserOrganizationDetailsViewQuery : IQuery<ProviderUserOrganizationDetails>
|
||||
{
|
||||
public IQueryable<ProviderUserOrganizationDetails> Run(DatabaseContext dbContext)
|
||||
{
|
||||
var query = from pu in dbContext.ProviderUsers
|
||||
join po in dbContext.ProviderOrganizations on pu.ProviderId equals po.ProviderId
|
||||
join o in dbContext.Organizations on po.OrganizationId equals o.Id
|
||||
join p in dbContext.Providers on pu.ProviderId equals p.Id
|
||||
select new { pu, po, o, p };
|
||||
return query.Select(x => new ProviderUserOrganizationDetails
|
||||
{
|
||||
OrganizationId = x.po.OrganizationId,
|
||||
UserId = x.pu.UserId,
|
||||
Name = x.o.Name,
|
||||
Enabled = x.o.Enabled,
|
||||
UsePolicies = x.o.UsePolicies,
|
||||
UseSso = x.o.UseSso,
|
||||
UseKeyConnector = x.o.UseKeyConnector,
|
||||
UseScim = x.o.UseScim,
|
||||
UseGroups = x.o.UseGroups,
|
||||
UseDirectory = x.o.UseDirectory,
|
||||
UseEvents = x.o.UseEvents,
|
||||
UseTotp = x.o.UseTotp,
|
||||
Use2fa = x.o.Use2fa,
|
||||
UseApi = x.o.UseApi,
|
||||
SelfHost = x.o.SelfHost,
|
||||
UsersGetPremium = x.o.UsersGetPremium,
|
||||
UseCustomPermissions = x.o.UseCustomPermissions,
|
||||
Seats = x.o.Seats,
|
||||
MaxCollections = x.o.MaxCollections,
|
||||
MaxStorageGb = x.o.MaxStorageGb,
|
||||
Identifier = x.o.Identifier,
|
||||
Key = x.po.Key,
|
||||
Status = x.pu.Status,
|
||||
Type = x.pu.Type,
|
||||
PublicKey = x.o.PublicKey,
|
||||
PrivateKey = x.o.PrivateKey,
|
||||
ProviderId = x.p.Id,
|
||||
ProviderName = x.p.Name,
|
||||
PlanType = x.o.PlanType
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Bit.Core.AdminConsole.Enums.Provider;
|
||||
using Bit.Core.AdminConsole.Models.Data.Provider;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.AdminConsole.Repositories.Queries;
|
||||
|
||||
public class ProviderUserProviderDetailsReadByUserIdStatusQuery : IQuery<ProviderUserProviderDetails>
|
||||
{
|
||||
private readonly Guid _userId;
|
||||
private readonly ProviderUserStatusType? _status;
|
||||
public ProviderUserProviderDetailsReadByUserIdStatusQuery(Guid userId, ProviderUserStatusType? status)
|
||||
{
|
||||
_userId = userId;
|
||||
_status = status;
|
||||
}
|
||||
|
||||
public IQueryable<ProviderUserProviderDetails> Run(DatabaseContext dbContext)
|
||||
{
|
||||
var query = from pu in dbContext.ProviderUsers
|
||||
join p in dbContext.Providers
|
||||
on pu.ProviderId equals p.Id into p_g
|
||||
from p in p_g.DefaultIfEmpty()
|
||||
where pu.UserId == _userId && p.Status != ProviderStatusType.Pending && (_status == null || pu.Status == _status)
|
||||
select new { pu, p };
|
||||
return query.Select(x => new ProviderUserProviderDetails()
|
||||
{
|
||||
UserId = x.pu.UserId,
|
||||
ProviderId = x.pu.ProviderId,
|
||||
Name = x.p.Name,
|
||||
Key = x.pu.Key,
|
||||
Status = x.pu.Status,
|
||||
Type = x.pu.Type,
|
||||
Enabled = x.p.Enabled,
|
||||
Permissions = x.pu.Permissions,
|
||||
UseEvents = x.p.UseEvents,
|
||||
ProviderStatus = x.p.Status,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user