mirror of
https://github.com/bitwarden/server
synced 2025-12-26 21:23:39 +00:00
[PM-25182] Improve swagger OperationIDs: Part 1 (#6229)
* Improve swagger OperationIDs: Part 1 * Fix tests and fmt * Improve docs and add more tests * Fmt * Improve Swagger OperationIDs for Auth * Fix review feedback * Use generic getcustomattributes * Format * replace swaggerexclude by split+obsolete * Format * Some remaining excludes
This commit is contained in:
@@ -75,7 +75,7 @@ public class DevicesController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("")]
|
||||
public async Task<ListResponseModel<DeviceAuthRequestResponseModel>> Get()
|
||||
public async Task<ListResponseModel<DeviceAuthRequestResponseModel>> GetAll()
|
||||
{
|
||||
var devicesWithPendingAuthData = await _deviceRepository.GetManyByUserIdWithDeviceAuth(_userService.GetProperUserId(User).Value);
|
||||
|
||||
@@ -99,7 +99,6 @@ public class DevicesController : Controller
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
[HttpPost("{id}")]
|
||||
public async Task<DeviceResponseModel> Put(string id, [FromBody] DeviceRequestModel model)
|
||||
{
|
||||
var device = await _deviceRepository.GetByIdAsync(new Guid(id), _userService.GetProperUserId(User).Value);
|
||||
@@ -114,8 +113,14 @@ public class DevicesController : Controller
|
||||
return response;
|
||||
}
|
||||
|
||||
[HttpPost("{id}")]
|
||||
[Obsolete("This endpoint is deprecated. Use PUT /{id} instead.")]
|
||||
public async Task<DeviceResponseModel> Post(string id, [FromBody] DeviceRequestModel model)
|
||||
{
|
||||
return await Put(id, model);
|
||||
}
|
||||
|
||||
[HttpPut("{identifier}/keys")]
|
||||
[HttpPost("{identifier}/keys")]
|
||||
public async Task<DeviceResponseModel> PutKeys(string identifier, [FromBody] DeviceKeysRequestModel model)
|
||||
{
|
||||
var device = await _deviceRepository.GetByIdentifierAsync(identifier, _userService.GetProperUserId(User).Value);
|
||||
@@ -130,6 +135,13 @@ public class DevicesController : Controller
|
||||
return response;
|
||||
}
|
||||
|
||||
[HttpPost("{identifier}/keys")]
|
||||
[Obsolete("This endpoint is deprecated. Use PUT /{identifier}/keys instead.")]
|
||||
public async Task<DeviceResponseModel> PostKeys(string identifier, [FromBody] DeviceKeysRequestModel model)
|
||||
{
|
||||
return await PutKeys(identifier, model);
|
||||
}
|
||||
|
||||
[HttpPost("{identifier}/retrieve-keys")]
|
||||
[Obsolete("This endpoint is deprecated. The keys are on the regular device GET endpoints now.")]
|
||||
public async Task<ProtectedDeviceResponseModel> GetDeviceKeys(string identifier)
|
||||
@@ -187,7 +199,6 @@ public class DevicesController : Controller
|
||||
}
|
||||
|
||||
[HttpPut("identifier/{identifier}/token")]
|
||||
[HttpPost("identifier/{identifier}/token")]
|
||||
public async Task PutToken(string identifier, [FromBody] DeviceTokenRequestModel model)
|
||||
{
|
||||
var device = await _deviceRepository.GetByIdentifierAsync(identifier, _userService.GetProperUserId(User).Value);
|
||||
@@ -199,8 +210,14 @@ public class DevicesController : Controller
|
||||
await _deviceService.SaveAsync(model.ToDevice(device));
|
||||
}
|
||||
|
||||
[HttpPost("identifier/{identifier}/token")]
|
||||
[Obsolete("This endpoint is deprecated. Use PUT /identifier/{identifier}/token instead.")]
|
||||
public async Task PostToken(string identifier, [FromBody] DeviceTokenRequestModel model)
|
||||
{
|
||||
await PutToken(identifier, model);
|
||||
}
|
||||
|
||||
[HttpPut("identifier/{identifier}/web-push-auth")]
|
||||
[HttpPost("identifier/{identifier}/web-push-auth")]
|
||||
public async Task PutWebPushAuth(string identifier, [FromBody] WebPushAuthRequestModel model)
|
||||
{
|
||||
var device = await _deviceRepository.GetByIdentifierAsync(identifier, _userService.GetProperUserId(User).Value);
|
||||
@@ -216,9 +233,15 @@ public class DevicesController : Controller
|
||||
);
|
||||
}
|
||||
|
||||
[HttpPost("identifier/{identifier}/web-push-auth")]
|
||||
[Obsolete("This endpoint is deprecated. Use PUT /identifier/{identifier}/web-push-auth instead.")]
|
||||
public async Task PostWebPushAuth(string identifier, [FromBody] WebPushAuthRequestModel model)
|
||||
{
|
||||
await PutWebPushAuth(identifier, model);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPut("identifier/{identifier}/clear-token")]
|
||||
[HttpPost("identifier/{identifier}/clear-token")]
|
||||
public async Task PutClearToken(string identifier)
|
||||
{
|
||||
var device = await _deviceRepository.GetByIdentifierAsync(identifier);
|
||||
@@ -230,8 +253,15 @@ public class DevicesController : Controller
|
||||
await _deviceService.ClearTokenAsync(device);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost("identifier/{identifier}/clear-token")]
|
||||
[Obsolete("This endpoint is deprecated. Use PUT /identifier/{identifier}/clear-token instead.")]
|
||||
public async Task PostClearToken(string identifier)
|
||||
{
|
||||
await PutClearToken(identifier);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[HttpPost("{id}/deactivate")]
|
||||
public async Task Deactivate(string id)
|
||||
{
|
||||
var device = await _deviceRepository.GetByIdAsync(new Guid(id), _userService.GetProperUserId(User).Value);
|
||||
@@ -243,17 +273,24 @@ public class DevicesController : Controller
|
||||
await _deviceService.DeactivateAsync(device);
|
||||
}
|
||||
|
||||
[HttpPost("{id}/deactivate")]
|
||||
[Obsolete("This endpoint is deprecated. Use DELETE /{id} instead.")]
|
||||
public async Task PostDeactivate(string id)
|
||||
{
|
||||
await Deactivate(id);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet("knowndevice")]
|
||||
public async Task<bool> GetByIdentifierQuery(
|
||||
[Required][FromHeader(Name = "X-Request-Email")] string Email,
|
||||
[Required][FromHeader(Name = "X-Device-Identifier")] string DeviceIdentifier)
|
||||
=> await GetByIdentifier(CoreHelpers.Base64UrlDecodeString(Email), DeviceIdentifier);
|
||||
=> await GetByEmailAndIdentifier(CoreHelpers.Base64UrlDecodeString(Email), DeviceIdentifier);
|
||||
|
||||
[Obsolete("Path is deprecated due to encoding issues, use /knowndevice instead.")]
|
||||
[AllowAnonymous]
|
||||
[HttpGet("knowndevice/{email}/{identifier}")]
|
||||
public async Task<bool> GetByIdentifier(string email, string identifier)
|
||||
public async Task<bool> GetByEmailAndIdentifier(string email, string identifier)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(identifier))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user