| | | 1 | | using ArturRios.Heimdall.Shared.Messages; |
| | | 2 | | using FluentValidation; |
| | | 3 | | |
| | | 4 | | namespace ArturRios.Heimdall.Command.Input.Validation; |
| | | 5 | | |
| | | 6 | | /// <summary>UC-56 AF-56a: the request names an application, a scope and a secret of bounded length.</summary> |
| | | 7 | | public class IssueApplicationTokenCommandValidator : AbstractValidator<IssueApplicationTokenCommand> |
| | | 8 | | { |
| | | 9 | | /// <summary>A secret is 47 characters; the bound only stops hashing an arbitrarily large body.</summary> |
| | | 10 | | private const int MaxSecretLength = 100; |
| | | 11 | | |
| | 24 | 12 | | public IssueApplicationTokenCommandValidator() |
| | | 13 | | { |
| | 24 | 14 | | RuleFor(command => command.ApplicationId) |
| | 24 | 15 | | .NotEmpty().WithMessage(ApplicationTokenMessages.ApplicationIdRequired); |
| | | 16 | | |
| | 24 | 17 | | RuleFor(command => command.ScopeId) |
| | 24 | 18 | | .NotEmpty().WithMessage(ApplicationTokenMessages.ScopeIdRequired); |
| | | 19 | | |
| | 24 | 20 | | RuleFor(command => command.Secret) |
| | 24 | 21 | | .NotEmpty().WithMessage(ApplicationTokenMessages.SecretRequired) |
| | 24 | 22 | | .MaximumLength(MaxSecretLength).WithMessage(ApplicationTokenMessages.SecretTooLong); |
| | 24 | 23 | | } |
| | | 24 | | } |