1
0
mirror of https://github.com/bitwarden/server synced 2026-01-01 08:03:23 +00:00

[PM- 22675] Send password auth method (#6228)

* feat: add Passwordvalidation
* fix: update strings to constants
* fix: add customResponse for rust consumption
* test: add tests for SendPasswordValidator. fix: update tests for SendAccessGrantValidator
* feat: update send access constants.
This commit is contained in:
Ike
2025-08-22 18:02:37 -04:00
committed by GitHub
parent 50b36bda2a
commit 3097e7f223
10 changed files with 647 additions and 76 deletions

View File

@@ -0,0 +1,73 @@
using Duende.IdentityServer.Validation;
namespace Bit.Identity.IdentityServer.RequestValidators.SendAccess;
/// <summary>
/// String constants for the Send Access user feature
/// </summary>
public static class SendAccessConstants
{
/// <summary>
/// A catch all error type for send access related errors. Used mainly in the <see cref="GrantValidationResult.CustomResponse"/>
/// </summary>
public const string SendAccessError = "send_access_error_type";
public static class TokenRequest
{
/// <summary>
/// used to fetch Send from database.
/// </summary>
public const string SendId = "send_id";
/// <summary>
/// used to validate Send protected passwords
/// </summary>
public const string ClientB64HashedPassword = "password_hash_b64";
/// <summary>
/// email used to see if email is associated with the Send
/// </summary>
public const string Email = "email";
/// <summary>
/// Otp code sent to email associated with the Send
/// </summary>
public const string Otp = "otp";
}
public static class GrantValidatorResults
{
/// <summary>
/// The sendId is valid and the request is well formed.
/// </summary>
public const string ValidSendGuid = "valid_send_guid";
/// <summary>
/// The sendId is missing from the request.
/// </summary>
public const string MissingSendId = "send_id_required";
/// <summary>
/// The sendId is invalid, does not match a known send.
/// </summary>
public const string InvalidSendId = "send_id_invalid";
}
public static class PasswordValidatorResults
{
/// <summary>
/// The passwordHashB64 does not match the send's password hash.
/// </summary>
public const string RequestPasswordDoesNotMatch = "password_hash_b64_invalid";
/// <summary>
/// The passwordHashB64 is missing from the request.
/// </summary>
public const string RequestPasswordIsRequired = "password_hash_b64_required";
}
public static class EmailOtpValidatorResults
{
/// <summary>
/// Represents the error code indicating that an email address is required.
/// </summary>
public const string EmailRequired = "email_required";
/// <summary>
/// Represents the status indicating that both email and OTP are required, and the OTP has been sent.
/// </summary>
public const string EmailOtpSent = "email_and_otp_required_otp_sent";
}
}