1
0
mirror of https://github.com/bitwarden/server synced 2025-12-26 05:03:18 +00:00
Files
server/src/Core/Auth/UserFeatures/UserKey/IRotateUserKeyCommand.cs
Jake Fink ca8e3f496e [PM-3797 Part 4] Add Sends to new Key Rotation (#3442)
* add send validation

* add send repo methods

* add send rotation to delegate list

* add success test
2023-12-12 11:58:34 -05:00

30 lines
1.3 KiB
C#

using Bit.Core.Auth.Models.Data;
using Bit.Core.Entities;
using Microsoft.AspNetCore.Identity;
using Microsoft.Data.SqlClient;
namespace Bit.Core.Auth.UserFeatures.UserKey;
/// <summary>
/// Responsible for rotation of a user key and updating database with re-encrypted data
/// </summary>
public interface IRotateUserKeyCommand
{
/// <summary>
/// Sets a new user key and updates all encrypted data.
/// </summary>
/// <param name="model">All necessary information for rotation. Warning: Any encrypted data not included will be lost.</param>
/// <returns>An IdentityResult for verification of the master password hash</returns>
/// <exception cref="ArgumentNullException">User must be provided.</exception>
Task<IdentityResult> RotateUserKeyAsync(User user, RotateUserKeyData model);
}
/// <summary>
/// A type used to implement updates to the database for key rotations. Each domain that requires an update of encrypted
/// data during a key rotation should use this to implement its own database call. The user repository loops through
/// these during a key rotation.
/// <para>Note: connection and transaction are only used for Dapper. They won't be available in EF</para>
/// </summary>
public delegate Task UpdateEncryptedDataForKeyRotation(SqlConnection connection = null,
SqlTransaction transaction = null);