Skip to content

Commit

Permalink
Added SecurityOptions.TokensExpirationInHours
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Vivet committed Nov 7, 2023
1 parent ff0e554 commit 5e2c282
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Nano.Security/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ private static IServiceCollection AddSecurityIdentity(this IServiceCollection se
x.Lockout.MaxFailedAccessAttempts = options.Lockout.MaxFailedAccessAttempts;
});

services
.Configure<DataProtectionTokenProviderOptions>(x =>
{
x.TokenLifespan = TimeSpan.FromHours(options.TokensExpirationInHours);
});

return services;
}
}
5 changes: 5 additions & 0 deletions Nano.Security/SecurityOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public class SecurityOptions
/// </summary>
public virtual bool IsAuth { get; set; } = true;

/// <summary>
/// Tokens Expiration.
/// </summary>
public virtual int TokensExpirationInHours { get; set; } = 24;

/// <summary>
/// Jwt Options.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions appsettings.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@
},
"Security": {
"IsAuth": true,
"TokensExpirationInHours": 24,
"Jwt": {
"Issuer": "issuer",
"Audience": "audience",
Expand Down

0 comments on commit 5e2c282

Please sign in to comment.