1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00

663-AccessTokens validate expiration date (#3104)

* 663-AccessTokens validate expiration date

* removing unecessary using statement

* thomas' suggested change

* Thomas' suggested change

* Update src/Api/SecretsManager/Models/Request/AccessTokenCreateRequestModel.cs

Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>

---------

Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
This commit is contained in:
cd-bitwarden 2023-08-04 16:21:51 -04:00 committed by GitHub
parent 222d57622e
commit 174d890234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@ using Bit.Core.Utilities;
namespace Bit.Api.SecretsManager.Models.Request;
public class AccessTokenCreateRequestModel
public class AccessTokenCreateRequestModel : IValidatableObject
{
[Required]
[EncryptedString]
@ -34,4 +34,13 @@ public class AccessTokenCreateRequestModel
EncryptedPayload = EncryptedPayload,
};
}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (ExpireAt != null && ExpireAt <= DateTime.UtcNow)
{
yield return new ValidationResult(
$"Please select an expiration date that is in the future.");
}
}
}