1
0
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:
Kyle Spearrin
2017-04-03 12:27:02 -04:00
parent 0961d86d65
commit f1fc7832a0
19 changed files with 230 additions and 17 deletions

View 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);
}
}
}

View File

@ -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 =>