mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
subvault user apis
This commit is contained in:
54
src/Api/Controllers/SubvaultUsersController.cs
Normal file
54
src/Api/Controllers/SubvaultUsersController.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Bit.Core.Repositories;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Services;
|
||||
|
||||
namespace Bit.Api.Controllers
|
||||
{
|
||||
[Route("organizations/{orgId}/subvaultUsers")]
|
||||
[Authorize("Application")]
|
||||
public class SubvaultUsersController : Controller
|
||||
{
|
||||
private readonly ISubvaultRepository _subvaultRepository;
|
||||
private readonly ISubvaultUserRepository _subvaultUserRepository;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public SubvaultUsersController(
|
||||
ISubvaultRepository subvaultRepository,
|
||||
ISubvaultUserRepository subvaultUserRepository,
|
||||
IUserService userService)
|
||||
{
|
||||
_subvaultRepository = subvaultRepository;
|
||||
_subvaultUserRepository = subvaultUserRepository;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
[HttpGet("{subvaultId}")]
|
||||
public async Task<ListResponseModel<SubvaultUserResponseModel>> GetBySubvault(string orgId, string subvaultId)
|
||||
{
|
||||
// TODO: permission check
|
||||
var subvaultUsers = await _subvaultUserRepository.GetManyDetailsBySubvaultIdAsync(new Guid(subvaultId));
|
||||
var responses = subvaultUsers.Select(s => new SubvaultUserResponseModel(s));
|
||||
return new ListResponseModel<SubvaultUserResponseModel>(responses);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[HttpPost("{id}/delete")]
|
||||
public async Task Delete(string orgId, string id)
|
||||
{
|
||||
var user = await _subvaultUserRepository.GetByIdAsync(new Guid(id));
|
||||
if(user == null)
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
// TODO: permission check
|
||||
await _subvaultUserRepository.DeleteAsync(user);
|
||||
}
|
||||
}
|
||||
}
|
@ -198,6 +198,7 @@ namespace Bit.Api
|
||||
services.AddScoped<IDeviceService, DeviceService>();
|
||||
services.AddScoped<IBlockIpService, AzureQueueBlockIpService>();
|
||||
services.AddScoped<IOrganizationService, OrganizationService>();
|
||||
services.AddScoped<ISubvaultService, SubvaultService>();
|
||||
|
||||
// Cors
|
||||
services.AddCors(config =>
|
||||
|
Reference in New Issue
Block a user