Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 114 additions & 18 deletions src/Api/Vault/Controllers/CiphersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public async Task<CipherMiniResponseModel> GetAdmin(string id)
return new CipherMiniDetailsResponseModel(cipher, _globalSettings, collectionCiphersGroupDict, cipher.OrganizationUseTotp);
}

[HttpGet("{id}/full-details")]
[HttpGet("{id}/details")]
public async Task<CipherDetailsResponseModel> GetDetails(Guid id)
{
Expand All @@ -124,8 +123,15 @@ public async Task<CipherDetailsResponseModel> GetDetails(Guid id)
return new CipherDetailsResponseModel(cipher, user, organizationAbilities, _globalSettings, collectionCiphers);
}

[HttpGet("{id}/full-details")]
[Obsolete("This endpoint is deprecated. Use GET details method instead.")]
public async Task<CipherDetailsResponseModel> GetFullDetails(Guid id)
{
return await GetDetails(id);
}

[HttpGet("")]
public async Task<ListResponseModel<CipherDetailsResponseModel>> Get()
public async Task<ListResponseModel<CipherDetailsResponseModel>> GetAll()
{
var user = await _userService.GetUserByPrincipalAsync(User);
var hasOrgs = _currentContext.Organizations.Count != 0;
Expand Down Expand Up @@ -232,7 +238,6 @@ public async Task<CipherMiniResponseModel> PostAdmin([FromBody] CipherCreateRequ
}

[HttpPut("{id}")]
[HttpPost("{id}")]
public async Task<CipherResponseModel> Put(Guid id, [FromBody] CipherRequestModel model)
{
var user = await _userService.GetUserByPrincipalAsync(User);
Expand Down Expand Up @@ -273,8 +278,14 @@ await _applicationCacheService.GetOrganizationAbilitiesAsync(),
return response;
}

[HttpPost("{id}")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherResponseModel> PostPut(Guid id, [FromBody] CipherRequestModel model)
{
return await Put(id, model);
}

[HttpPut("{id}/admin")]
[HttpPost("{id}/admin")]
public async Task<CipherMiniResponseModel> PutAdmin(Guid id, [FromBody] CipherRequestModel model)
{
var userId = _userService.GetProperUserId(User).Value;
Expand Down Expand Up @@ -307,6 +318,13 @@ public async Task<CipherMiniResponseModel> PutAdmin(Guid id, [FromBody] CipherRe
return response;
}

[HttpPost("{id}/admin")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherMiniResponseModel> PostPutAdmin(Guid id, [FromBody] CipherRequestModel model)
{
return await PutAdmin(id, model);
}

[HttpGet("organization-details")]
public async Task<ListResponseModel<CipherMiniDetailsResponseModel>> GetOrganizationCiphers(Guid organizationId)
{
Expand Down Expand Up @@ -678,7 +696,6 @@ private async Task<bool> CanEditItemsInCollections(Guid organizationId, IEnumera
}

[HttpPut("{id}/partial")]
[HttpPost("{id}/partial")]
public async Task<CipherResponseModel> PutPartial(Guid id, [FromBody] CipherPartialRequestModel model)
{
var user = await _userService.GetUserByPrincipalAsync(User);
Expand All @@ -694,8 +711,14 @@ await _applicationCacheService.GetOrganizationAbilitiesAsync(),
return response;
}

[HttpPost("{id}/partial")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherResponseModel> PostPartial(Guid id, [FromBody] CipherPartialRequestModel model)
{
return await PutPartial(id, model);
}

[HttpPut("{id}/share")]
[HttpPost("{id}/share")]
public async Task<CipherResponseModel> PutShare(Guid id, [FromBody] CipherShareRequestModel model)
{
var user = await _userService.GetUserByPrincipalAsync(User);
Expand Down Expand Up @@ -731,8 +754,14 @@ await _applicationCacheService.GetOrganizationAbilitiesAsync(),
return response;
}

[HttpPost("{id}/share")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherResponseModel> PostShare(Guid id, [FromBody] CipherShareRequestModel model)
{
return await PutShare(id, model);
}

[HttpPut("{id}/collections")]
[HttpPost("{id}/collections")]
public async Task<CipherDetailsResponseModel> PutCollections(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
var user = await _userService.GetUserByPrincipalAsync(User);
Expand All @@ -757,8 +786,14 @@ await _applicationCacheService.GetOrganizationAbilitiesAsync(),
collectionCiphers);
}

[HttpPost("{id}/collections")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherDetailsResponseModel> PostCollections(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutCollections(id, model);
}

[HttpPut("{id}/collections_v2")]
[HttpPost("{id}/collections_v2")]
public async Task<OptionalCipherDetailsResponseModel> PutCollections_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
var user = await _userService.GetUserByPrincipalAsync(User);
Expand Down Expand Up @@ -791,8 +826,14 @@ await _applicationCacheService.GetOrganizationAbilitiesAsync(),
return response;
}

[HttpPost("{id}/collections_v2")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<OptionalCipherDetailsResponseModel> PostCollections_vNext(Guid id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutCollections_vNext(id, model);
}

[HttpPut("{id}/collections-admin")]
[HttpPost("{id}/collections-admin")]
public async Task<CipherMiniDetailsResponseModel> PutCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
{
var userId = _userService.GetProperUserId(User).Value;
Expand Down Expand Up @@ -821,6 +862,13 @@ public async Task<CipherMiniDetailsResponseModel> PutCollectionsAdmin(string id,
return new CipherMiniDetailsResponseModel(cipher, _globalSettings, collectionCiphersGroupDict, cipher.OrganizationUseTotp);
}

[HttpPost("{id}/collections-admin")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<CipherMiniDetailsResponseModel> PostCollectionsAdmin(string id, [FromBody] CipherCollectionsRequestModel model)
{
return await PutCollectionsAdmin(id, model);
}

[HttpPost("bulk-collections")]
public async Task PostBulkCollections([FromBody] CipherBulkUpdateCollectionsRequestModel model)
{
Expand All @@ -841,7 +889,6 @@ public async Task PostBulkCollections([FromBody] CipherBulkUpdateCollectionsRequ
}

[HttpDelete("{id}")]
[HttpPost("{id}/delete")]
public async Task Delete(Guid id)
{
var userId = _userService.GetProperUserId(User).Value;
Expand All @@ -854,8 +901,14 @@ public async Task Delete(Guid id)
await _cipherService.DeleteAsync(cipher, userId);
}

[HttpPost("{id}/delete")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task PostDelete(Guid id)
{
await Delete(id);
}

[HttpDelete("{id}/admin")]
[HttpPost("{id}/delete-admin")]
public async Task DeleteAdmin(Guid id)
{
var userId = _userService.GetProperUserId(User).Value;
Expand All @@ -869,8 +922,14 @@ public async Task DeleteAdmin(Guid id)
await _cipherService.DeleteAsync(cipher, userId, true);
}

[HttpPost("{id}/delete-admin")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task PostDeleteAdmin(Guid id)
{
await DeleteAdmin(id);
}

[HttpDelete("")]
[HttpPost("delete")]
public async Task DeleteMany([FromBody] CipherBulkDeleteRequestModel model)
{
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
Expand All @@ -883,8 +942,14 @@ public async Task DeleteMany([FromBody] CipherBulkDeleteRequestModel model)
await _cipherService.DeleteManyAsync(model.Ids.Select(i => new Guid(i)), userId);
}

[HttpPost("delete")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task PostDeleteMany([FromBody] CipherBulkDeleteRequestModel model)
{
await DeleteMany(model);
}

[HttpDelete("admin")]
[HttpPost("delete-admin")]
public async Task DeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model)
{
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
Expand All @@ -910,6 +975,13 @@ public async Task DeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model)
await _cipherService.DeleteManyAsync(cipherIds, userId, new Guid(model.OrganizationId), true);
}

[HttpPost("delete-admin")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task PostDeleteManyAdmin([FromBody] CipherBulkDeleteRequestModel model)
{
await DeleteManyAdmin(model);
}

[HttpPut("{id}/delete")]
public async Task PutDelete(Guid id)
{
Expand Down Expand Up @@ -1050,7 +1122,6 @@ public async Task<ListResponseModel<CipherMiniResponseModel>> PutRestoreManyAdmi
}

[HttpPut("move")]
[HttpPost("move")]
public async Task MoveMany([FromBody] CipherBulkMoveRequestModel model)
{
if (!_globalSettings.SelfHosted && model.Ids.Count() > 500)
Expand All @@ -1063,8 +1134,14 @@ public async Task MoveMany([FromBody] CipherBulkMoveRequestModel model)
string.IsNullOrWhiteSpace(model.FolderId) ? (Guid?)null : new Guid(model.FolderId), userId);
}

[HttpPost("move")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task PostMoveMany([FromBody] CipherBulkMoveRequestModel model)
{
await MoveMany(model);
}

[HttpPut("share")]
[HttpPost("share")]
public async Task<ListResponseModel<CipherMiniResponseModel>> PutShareMany([FromBody] CipherBulkShareRequestModel model)
{
var organizationId = new Guid(model.Ciphers.First().OrganizationId);
Expand Down Expand Up @@ -1112,6 +1189,13 @@ public async Task<ListResponseModel<CipherMiniResponseModel>> PutShareMany([From
return new ListResponseModel<CipherMiniResponseModel>(response);
}

[HttpPost("share")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<ListResponseModel<CipherMiniResponseModel>> PostShareMany([FromBody] CipherBulkShareRequestModel model)
{
return await PutShareMany(model);
}

[HttpPost("purge")]
public async Task PostPurge([FromBody] SecretVerificationRequestModel model, Guid? organizationId = null)
{
Expand Down Expand Up @@ -1230,7 +1314,7 @@ await Request.GetFileAsync(async (stream) =>
[Obsolete("Deprecated Attachments API", false)]
[RequestSizeLimit(Constants.FileSize101mb)]
[DisableFormValueModelBinding]
public async Task<CipherResponseModel> PostAttachment(Guid id)
public async Task<CipherResponseModel> PostAttachmentV1(Guid id)
{
ValidateAttachment();

Expand Down Expand Up @@ -1324,7 +1408,6 @@ await _cipherService.CreateAttachmentShareAsync(cipher, stream, fileName, key,
}

[HttpDelete("{id}/attachment/{attachmentId}")]
[HttpPost("{id}/attachment/{attachmentId}/delete")]
public async Task<DeleteAttachmentResponseData> DeleteAttachment(Guid id, string attachmentId)
{
var userId = _userService.GetProperUserId(User).Value;
Expand All @@ -1337,8 +1420,14 @@ public async Task<DeleteAttachmentResponseData> DeleteAttachment(Guid id, string
return await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, false);
}

[HttpPost("{id}/attachment/{attachmentId}/delete")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task<DeleteAttachmentResponseData> PostDeleteAttachment(Guid id, string attachmentId)
{
return await DeleteAttachment(id, attachmentId);
}

[HttpDelete("{id}/attachment/{attachmentId}/admin")]
[HttpPost("{id}/attachment/{attachmentId}/delete-admin")]
public async Task<DeleteAttachmentResponseData> DeleteAttachmentAdmin(Guid id, string attachmentId)
{
var userId = _userService.GetProperUserId(User).Value;
Expand All @@ -1352,6 +1441,13 @@ public async Task<DeleteAttachmentResponseData> DeleteAttachmentAdmin(Guid id, s
return await _cipherService.DeleteAttachmentAsync(cipher, attachmentId, userId, true);
}

[HttpPost("{id}/attachment/{attachmentId}/delete-admin")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task<DeleteAttachmentResponseData> PostDeleteAttachmentAdmin(Guid id, string attachmentId)
{
return await DeleteAttachmentAdmin(id, attachmentId);
}

[AllowAnonymous]
[HttpPost("attachment/validate/azure")]
public async Task<ObjectResult> AzureValidateFile()
Expand Down
18 changes: 15 additions & 3 deletions src/Api/Vault/Controllers/FoldersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task<FolderResponseModel> Get(string id)
}

[HttpGet("")]
public async Task<ListResponseModel<FolderResponseModel>> Get()
public async Task<ListResponseModel<FolderResponseModel>> GetAll()
{
var userId = _userService.GetProperUserId(User).Value;
var folders = await _folderRepository.GetManyByUserIdAsync(userId);
Expand All @@ -63,7 +63,6 @@ public async Task<FolderResponseModel> Post([FromBody] FolderRequestModel model)
}

[HttpPut("{id}")]
[HttpPost("{id}")]
public async Task<FolderResponseModel> Put(string id, [FromBody] FolderRequestModel model)
{
var userId = _userService.GetProperUserId(User).Value;
Expand All @@ -77,8 +76,14 @@ public async Task<FolderResponseModel> Put(string id, [FromBody] FolderRequestMo
return new FolderResponseModel(folder);
}

[HttpPost("{id}")]
[Obsolete("This endpoint is deprecated. Use PUT method instead.")]
public async Task<FolderResponseModel> PostPut(string id, [FromBody] FolderRequestModel model)
{
return await Put(id, model);
}

[HttpDelete("{id}")]
[HttpPost("{id}/delete")]
public async Task Delete(string id)
{
var userId = _userService.GetProperUserId(User).Value;
Expand All @@ -91,6 +96,13 @@ public async Task Delete(string id)
await _cipherService.DeleteFolderAsync(folder);
}

[HttpPost("{id}/delete")]
[Obsolete("This endpoint is deprecated. Use DELETE method instead.")]
public async Task PostDelete(string id)
{
await Delete(id);
}

[HttpDelete("all")]
public async Task DeleteAll()
{
Expand Down
Loading