|
|
|
@ -91,11 +91,11 @@ public class UserContext<TId>(
|
|
|
|
|
|
|
|
|
|
public JwtTokenInfo GenerateTokenInfo(
|
|
|
|
|
IList<Claim>? claims = null,
|
|
|
|
|
double? duration = null,
|
|
|
|
|
double duration = 0,
|
|
|
|
|
string schemeName = JwtBearerDefaults.AuthenticationScheme)
|
|
|
|
|
{
|
|
|
|
|
claims ??= GetClaimsFromUserContext();
|
|
|
|
|
if (double.NaN == duration)
|
|
|
|
|
if (0 == duration)
|
|
|
|
|
{
|
|
|
|
|
duration = jwtContext.Duration;
|
|
|
|
|
}
|
|
|
|
@ -106,12 +106,12 @@ public class UserContext<TId>(
|
|
|
|
|
Audience = jwtContext.Audience,
|
|
|
|
|
Claims = claims?.ToDictionary(c => c.Type, c => (object)c.Value),
|
|
|
|
|
NotBefore = DateTime.Now,
|
|
|
|
|
Expires = DateTime.Now.AddSeconds(duration.Value),
|
|
|
|
|
Expires = DateTime.Now.AddSeconds(duration),
|
|
|
|
|
SigningCredentials = jwtContext.SigningCredentials,
|
|
|
|
|
};
|
|
|
|
|
var token = jsonWebTokenHandler.CreateToken(tokenDescriptor);
|
|
|
|
|
token = encryptionService.Encrypt(token);
|
|
|
|
|
return new JwtTokenInfo(token, duration.Value, schemeName);
|
|
|
|
|
return new JwtTokenInfo(token, duration, schemeName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IList<Claim>? GetClaimsFromUserContext(bool includePermissions = false)
|
|
|
|
|