-
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1db1e63
commit 07d3231
Showing
16 changed files
with
60 additions
and
62 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
Binary file not shown.
6 changes: 0 additions & 6 deletions
6
...anArchitecture.Infrastructure/Common/Security/CurrentUserProvider/ICurrentUserProvider.cs
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...e/Common/Security/AuthorizationService.cs → ...tructure/Security/AuthorizationService.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
2 changes: 1 addition & 1 deletion
2
...curity/CurrentUserProvider/CurrentUser.cs → ...curity/CurrentUserProvider/CurrentUser.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
2 changes: 0 additions & 2 deletions
2
...urrentUserProvider/CurrentUserProvider.cs → ...urrentUserProvider/CurrentUserProvider.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
6 changes: 6 additions & 0 deletions
6
src/CleanArchitecture.Infrastructure/Security/CurrentUserProvider/ICurrentUserProvider.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace CleanArchitecture.Infrastructure.Security.CurrentUserProvider; | ||
|
||
public interface ICurrentUserProvider | ||
{ | ||
CurrentUser GetCurrentUser(); | ||
} |
2 changes: 1 addition & 1 deletion
2
...ecurity/PolicyEnforcer/IPolicyEnforcer.cs → ...ecurity/PolicyEnforcer/IPolicyEnforcer.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
2 changes: 1 addition & 1 deletion
2
...Security/PolicyEnforcer/PolicyEnforcer.cs → ...Security/PolicyEnforcer/PolicyEnforcer.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
File renamed without changes.
File renamed without changes.
64 changes: 32 additions & 32 deletions
64
...re/Configuration/JwtBearerOptionsSetup.cs → .../JwtBearerTokenValidationConfiguration.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,32 +1,32 @@ | ||
using System.Text; | ||
|
||
using CleanArchitecture.Infrastructure.Security.TokenGenerator; | ||
|
||
using Microsoft.AspNetCore.Authentication.JwtBearer; | ||
using Microsoft.Extensions.Options; | ||
using Microsoft.IdentityModel.Tokens; | ||
|
||
namespace CleanArchitecture.Infrastructure.Configuration; | ||
|
||
public sealed class JwtBearerOptionsSetup(IOptions<JwtSettings> jwtSettings) | ||
: IConfigureNamedOptions<JwtBearerOptions> | ||
{ | ||
private readonly JwtSettings _jwtSettings = jwtSettings.Value; | ||
|
||
public void Configure(string? name, JwtBearerOptions options) => Configure(options); | ||
|
||
public void Configure(JwtBearerOptions options) | ||
{ | ||
options.TokenValidationParameters = new TokenValidationParameters | ||
{ | ||
ValidateIssuer = true, | ||
ValidateAudience = true, | ||
ValidateLifetime = true, | ||
ValidateIssuerSigningKey = true, | ||
ValidIssuer = _jwtSettings.Issuer, | ||
ValidAudience = _jwtSettings.Audience, | ||
IssuerSigningKey = new SymmetricSecurityKey( | ||
Encoding.UTF8.GetBytes(_jwtSettings.Secret)), | ||
}; | ||
} | ||
} | ||
using System.Text; | ||
|
||
using CleanArchitecture.Infrastructure.Security.TokenGenerator; | ||
|
||
using Microsoft.AspNetCore.Authentication.JwtBearer; | ||
using Microsoft.Extensions.Options; | ||
using Microsoft.IdentityModel.Tokens; | ||
|
||
namespace CleanArchitecture.Infrastructure.Security.TokenValidation; | ||
|
||
public sealed class JwtBearerTokenValidationConfiguration(IOptions<JwtSettings> jwtSettings) | ||
: IConfigureNamedOptions<JwtBearerOptions> | ||
{ | ||
private readonly JwtSettings _jwtSettings = jwtSettings.Value; | ||
|
||
public void Configure(string? name, JwtBearerOptions options) => Configure(options); | ||
|
||
public void Configure(JwtBearerOptions options) | ||
{ | ||
options.TokenValidationParameters = new TokenValidationParameters | ||
{ | ||
ValidateIssuer = true, | ||
ValidateAudience = true, | ||
ValidateLifetime = true, | ||
ValidateIssuerSigningKey = true, | ||
ValidIssuer = _jwtSettings.Issuer, | ||
ValidAudience = _jwtSettings.Audience, | ||
IssuerSigningKey = new SymmetricSecurityKey( | ||
Encoding.UTF8.GetBytes(_jwtSettings.Secret)), | ||
}; | ||
} | ||
} |
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