mirror of
https://github.com/bitwarden/server.git
synced 2025-06-20 02:48:03 -05:00
Apply suggestions
This commit is contained in:
parent
4d6b8c88fc
commit
ad32c5f257
@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using UserKeyResponseModel = Bit.Api.Models.Response.UserKeyResponseModel;
|
using UserKeyResponseModel = Bit.Api.Models.Response.UserKeyResponseModel;
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
namespace Bit.Api.KeyManagement.Controllers;
|
namespace Bit.Api.KeyManagement.Controllers;
|
||||||
|
|
||||||
[Route("users")]
|
[Route("users")]
|
||||||
@ -22,11 +24,10 @@ public class UsersController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id}/public-key")]
|
[HttpGet("{id}/public-key")]
|
||||||
public async Task<UserKeyResponseModel> GetPublicKeyAsync(string id)
|
public async Task<UserKeyResponseModel> GetPublicKeyAsync([FromRoute] Guid id)
|
||||||
{
|
{
|
||||||
var guidId = new Guid(id);
|
var key = await _userRepository.GetPublicKeyAsync(id) ?? throw new NotFoundException();
|
||||||
var key = await _userRepository.GetPublicKeyAsync(guidId) ?? throw new NotFoundException();
|
return new UserKeyResponseModel(id, key);
|
||||||
return new UserKeyResponseModel(guidId, key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id}/keys")]
|
[HttpGet("{id}/keys")]
|
||||||
|
@ -14,6 +14,10 @@ namespace Bit.Api.KeyManagement.Models.Response;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PrivateKeysResponseModel : ResponseModel
|
public class PrivateKeysResponseModel : ResponseModel
|
||||||
{
|
{
|
||||||
|
// Not all accounts have signature keys, but all accounts have public encryption keys.
|
||||||
|
public SignatureKeyPairResponseModel? SignatureKeyPair { get; set; }
|
||||||
|
public required PublicKeyEncryptionKeyPairModel PublicKeyEncryptionKeyPair { get; set; }
|
||||||
|
|
||||||
[System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute]
|
[System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute]
|
||||||
public PrivateKeysResponseModel(UserAccountKeysData accountKeys) : base("privateKeys")
|
public PrivateKeysResponseModel(UserAccountKeysData accountKeys) : base("privateKeys")
|
||||||
{
|
{
|
||||||
@ -33,9 +37,4 @@ public class PrivateKeysResponseModel : ResponseModel
|
|||||||
SignatureKeyPair = signatureKeyPair;
|
SignatureKeyPair = signatureKeyPair;
|
||||||
PublicKeyEncryptionKeyPair = publicKeyEncryptionKeyPair ?? throw new ArgumentNullException(nameof(publicKeyEncryptionKeyPair));
|
PublicKeyEncryptionKeyPair = publicKeyEncryptionKeyPair ?? throw new ArgumentNullException(nameof(publicKeyEncryptionKeyPair));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not all accounts have signature keys, but all accounts have public encryption keys.
|
|
||||||
public SignatureKeyPairResponseModel? SignatureKeyPair { get; set; }
|
|
||||||
public required PublicKeyEncryptionKeyPairModel PublicKeyEncryptionKeyPair { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ public class PublicKeysResponseModel : ResponseModel
|
|||||||
public PublicKeysResponseModel(UserAccountKeysData accountKeys)
|
public PublicKeysResponseModel(UserAccountKeysData accountKeys)
|
||||||
: base("publicKeys")
|
: base("publicKeys")
|
||||||
{
|
{
|
||||||
PublicKey = accountKeys.PublicKeyEncryptionKeyPairData.PublicKey;
|
|
||||||
ArgumentNullException.ThrowIfNull(accountKeys);
|
ArgumentNullException.ThrowIfNull(accountKeys);
|
||||||
|
PublicKey = accountKeys.PublicKeyEncryptionKeyPairData.PublicKey;
|
||||||
|
|
||||||
if (accountKeys.SignatureKeyPairData != null)
|
if (accountKeys.SignatureKeyPairData != null)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user