diff --git a/Nano.Security/Extensions/ServiceCollectionExtensions.cs b/Nano.Security/Extensions/ServiceCollectionExtensions.cs index 4bd09bc..35fca51 100644 --- a/Nano.Security/Extensions/ServiceCollectionExtensions.cs +++ b/Nano.Security/Extensions/ServiceCollectionExtensions.cs @@ -101,6 +101,12 @@ private static IServiceCollection AddSecurityIdentity(this IServiceCollection se x.Lockout.MaxFailedAccessAttempts = options.Lockout.MaxFailedAccessAttempts; }); + services + .Configure(x => + { + x.TokenLifespan = TimeSpan.FromHours(options.TokensExpirationInHours); + }); + return services; } } \ No newline at end of file diff --git a/Nano.Security/SecurityOptions.cs b/Nano.Security/SecurityOptions.cs index f63d139..72bf685 100644 --- a/Nano.Security/SecurityOptions.cs +++ b/Nano.Security/SecurityOptions.cs @@ -18,6 +18,11 @@ public class SecurityOptions /// public virtual bool IsAuth { get; set; } = true; + /// + /// Tokens Expiration. + /// + public virtual int TokensExpirationInHours { get; set; } = 24; + /// /// Jwt Options. /// diff --git a/appsettings.default.json b/appsettings.default.json index 631e580..d9aead4 100644 --- a/appsettings.default.json +++ b/appsettings.default.json @@ -438,6 +438,7 @@ }, "Security": { "IsAuth": true, + "TokensExpirationInHours": 24, "Jwt": { "Issuer": "issuer", "Audience": "audience",