-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(auth): use generic security entities
- Loading branch information
1 parent
db0a8b5
commit 6214dfb
Showing
82 changed files
with
406 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 15 additions & 3 deletions
18
src/starterProject/Application/Features/Auth/Commands/Register/RegisterCommandValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
using FluentValidation; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Application.Features.Auth.Commands.Register; | ||
|
||
public class RegisterCommandValidator : AbstractValidator<RegisterCommand> | ||
{ | ||
public RegisterCommandValidator() | ||
{ | ||
RuleFor(c => c.UserForRegisterDto.FirstName).NotEmpty().MinimumLength(2); | ||
RuleFor(c => c.UserForRegisterDto.LastName).NotEmpty().MinimumLength(2); | ||
RuleFor(c => c.UserForRegisterDto.Email).NotEmpty().EmailAddress(); | ||
RuleFor(c => c.UserForRegisterDto.Password).NotEmpty().MinimumLength(4); | ||
RuleFor(c => c.UserForRegisterDto.Password) | ||
.NotEmpty() | ||
.MinimumLength(6) | ||
.Must(StrongPassword) | ||
.WithMessage( | ||
"Password must contain at least one uppercase letter, one lowercase letter, one number and one special character." | ||
); | ||
} | ||
|
||
private bool StrongPassword(string value) | ||
{ | ||
Regex strongPasswordRegex = new("^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$", RegexOptions.Compiled); | ||
|
||
return strongPasswordRegex.IsMatch(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 12 additions & 5 deletions
17
src/starterProject/Application/Features/Auth/Constants/AuthOperationClaims.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
namespace Application.Features.Auth.Constants; | ||
using Core.Security.Attributes; | ||
|
||
namespace Application.Features.Auth.Constants; | ||
|
||
[OperationClaimConstants] | ||
public static class AuthOperationClaims | ||
{ | ||
public const string Admin = "Auth.Admin"; | ||
public const string Write = "Auth.Write"; | ||
public const string Read = "Auth.Read"; | ||
public const string RevokeToken = "Auth.RevokeToken"; | ||
private const string _section = "Auth"; | ||
|
||
public const string Admin = $"{_section}.Admin"; | ||
|
||
public const string Write = $"{_section}.Write"; | ||
public const string Read = $"{_section}.Read"; | ||
|
||
public const string RevokeToken = $"{_section}.RevokeToken"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.