Fix Key Generation
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using ReallifeGamemode.Database;
|
||||
@@ -15,11 +16,13 @@ namespace ReallifeGamemode.DataService.Logic
|
||||
{
|
||||
public class JwtTokenGenerator : LogicBase
|
||||
{
|
||||
private ServerConfig config;
|
||||
private readonly ILogger<JwtTokenGenerator> logger;
|
||||
private readonly ServerConfig config;
|
||||
|
||||
public JwtTokenGenerator(IOptions<ServerConfig> config, DatabaseContext dbContext) : base(dbContext)
|
||||
public JwtTokenGenerator(IOptions<ServerConfig> config, DatabaseContext dbContext, ILogger<JwtTokenGenerator> logger) : base(dbContext)
|
||||
{
|
||||
this.config = config.Value;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public string GenerateUserToken(User user)
|
||||
@@ -40,10 +43,9 @@ namespace ReallifeGamemode.DataService.Logic
|
||||
new Claim(ClaimTypes.Name, user.Id.ToString()),
|
||||
new Claim(ClaimTypes.Role, user.AdminLevel.ToString())
|
||||
}),
|
||||
Expires = DateTime.Now.AddDays(1),
|
||||
IssuedAt = DateTime.Now,
|
||||
Expires = DateTime.UtcNow.AddDays(1),
|
||||
IssuedAt = DateTime.UtcNow,
|
||||
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature),
|
||||
Issuer = "LOGDATASERVICE"
|
||||
};
|
||||
|
||||
var token = tokenHandler.WriteToken(tokenHandler.CreateToken(tokenDescriptor));
|
||||
@@ -62,10 +64,9 @@ namespace ReallifeGamemode.DataService.Logic
|
||||
new Claim(ClaimTypes.Name, 1.ToString()),
|
||||
new Claim(ClaimTypes.Role, (AdminLevel.PROJEKTLEITUNG).ToString())
|
||||
}),
|
||||
Expires = DateTime.Now.AddDays(1),
|
||||
IssuedAt = DateTime.Now,
|
||||
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature),
|
||||
Issuer = "LOGDATASERVICE"
|
||||
Expires = DateTime.UtcNow.AddDays(1),
|
||||
IssuedAt = DateTime.UtcNow,
|
||||
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
|
||||
};
|
||||
|
||||
var token = tokenHandler.WriteToken(tokenHandler.CreateToken(tokenDescriptor));
|
||||
|
||||
Reference in New Issue
Block a user