Skip to content
Snippets Groups Projects
Commit 9a3ad3b5 authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Update: JWT Token validity set to a day (coscine/issues#2066)

parent ff5685f0
No related branches found
No related tags found
No related merge requests found
Pipeline #681782 passed
......@@ -25,8 +25,8 @@ namespace Coscine.JwtHandler
Configuration = configuration;
_jwtSecurityTokenHandler = new JwtSecurityTokenHandler();
_symmetricSecurityKey = GetSecurityKey();
_centuryBegin = new DateTime(1970, 1, 1);
_defaultExpiration = 30;
_centuryBegin = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
_defaultExpiration = 1440;
_issuer = "https://coscine.rwth-aachen.de";
_audience = "https://coscine.rwth-aachen.de";
}
......@@ -52,7 +52,9 @@ namespace Coscine.JwtHandler
ValidateIssuerSigningKey = true,
IssuerSigningKey = _symmetricSecurityKey,
ValidateIssuer = false,
ValidateAudience = false
ValidateAudience = false,
// set clockskew to zero so tokens expire exactly at token expiration time (instead of 5 minutes later)
ClockSkew = TimeSpan.Zero
};
_jwtSecurityTokenHandler.ValidateToken(token, tokenValidationParameters, out _);
......@@ -66,7 +68,7 @@ namespace Coscine.JwtHandler
public string GenerateJwtToken(JwtPayload payload, string signatureAlgorithm = "HS256")
{
var issuedAt = DateTime.Now;
var issuedAt = DateTime.UtcNow;
var expires = issuedAt.AddMinutes(_defaultExpiration);
return GenerateJwtToken(payload, _issuer, _audience, issuedAt, expires, signatureAlgorithm);
}
......
......@@ -6,11 +6,11 @@
using System.Reflection;
[assembly: AssemblyTitle("JwtHandler")]
[assembly: AssemblyDescription("JwtHandler is a part of the CoScInE group.")]
[assembly: AssemblyDescription("JwtHandler is a part of the Coscine group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("JwtHandler")]
[assembly: AssemblyVersion("1.2.0")]
[assembly: AssemblyFileVersion("1.2.0")]
[assembly: AssemblyInformationalVersion("1.2.0-topic-1125-apito0005")]
[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
[assembly: AssemblyCopyright("2022 IT Center, RWTH Aachen University")]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment