Fix Key Generation
This commit is contained in:
@@ -12,6 +12,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Logging;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
@@ -23,17 +24,21 @@ namespace ReallifeGamemode.DataService
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
private readonly ILogger<Startup> logger;
|
||||
private readonly IConfiguration configuration;
|
||||
private readonly IHostingEnvironment environment;
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
public Startup(IConfiguration configuration, IHostingEnvironment environment, ILogger<Startup> logger)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
this.environment = environment;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.Configure<ServerConfig>(cfg => Configuration.Bind(cfg));
|
||||
services.Configure<ServerConfig>(cfg => configuration.Bind(cfg));
|
||||
|
||||
services.AddDbContext<DatabaseContext>();
|
||||
|
||||
@@ -48,7 +53,7 @@ namespace ReallifeGamemode.DataService
|
||||
j.SerializerSettings.DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat;
|
||||
});
|
||||
|
||||
var tokenKey = Encoding.UTF8.GetBytes(Configuration["TokenSecret"]);
|
||||
var tokenKey = Encoding.ASCII.GetBytes(configuration["TokenSecret"]);
|
||||
services.AddAuthentication(o =>
|
||||
{
|
||||
o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
@@ -56,7 +61,8 @@ namespace ReallifeGamemode.DataService
|
||||
})
|
||||
.AddJwtBearer(o =>
|
||||
{
|
||||
o.RequireHttpsMetadata = true;
|
||||
o.IncludeErrorDetails = true;
|
||||
o.RequireHttpsMetadata = this.environment.IsProduction();
|
||||
o.SaveToken = false;
|
||||
o.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user