-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Configura a autenticação usando JWT Bearer
- Loading branch information
1 parent
ee6d23a
commit d95b82d
Showing
10 changed files
with
89 additions
and
34 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace JwtStore.Infrastructure.Authentication; | ||
|
||
public sealed class JwtOptions | ||
{ | ||
public const string SectionName = "Jwt"; | ||
|
||
public string Audience { get; init; } = string.Empty; | ||
|
||
public string Issuer { get; init; } = string.Empty; | ||
|
||
public string PrivateKey { get; init; } = string.Empty; | ||
|
||
public int TokenExpirationInMinutes { get; init; } | ||
} |
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,14 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace JwtStore.Infrastructure.Authentication; | ||
|
||
public sealed class JwtOptionsSetup(IConfiguration configuration) | ||
: IConfigureOptions<JwtOptions> | ||
{ | ||
private readonly IConfiguration _configuration = configuration; | ||
|
||
public void Configure(JwtOptions options) | ||
=> _configuration.GetSection(JwtOptions.SectionName) | ||
.Bind(options); | ||
} |
38 changes: 38 additions & 0 deletions
38
JwtStore.Infrastructure/Extensions/ServiceCollectionExtensions.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace JwtStore.Infrastructure.Options; | ||
|
||
public sealed class SecretsOptionsSetup(IConfiguration configuration) | ||
: IConfigureOptions<SecretsOptions> | ||
{ | ||
private readonly IConfiguration _configuration = configuration; | ||
|
||
public void Configure(SecretsOptions options) | ||
=> _configuration.GetSection(SecretsOptions.SectionName) | ||
.Bind(options); | ||
} |