diff options
| author | transtrike <transtrike@gmail.com> | 2020-12-12 15:58:55 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2020-12-12 15:58:55 +0200 |
| commit | 9fe564d452af7d5023cc410cd26761ba05730dc3 (patch) | |
| tree | 8465dc4d35c3f0aefe1f269be39448e553f34021 /API/Startup.cs | |
| parent | 9263e0c66aa7463975635a36ddcc85b45af0c66c (diff) | |
| download | DevHive-9fe564d452af7d5023cc410cd26761ba05730dc3.tar DevHive-9fe564d452af7d5023cc410cd26761ba05730dc3.tar.gz DevHive-9fe564d452af7d5023cc410cd26761ba05730dc3.zip | |
Last push cleanup
Diffstat (limited to 'API/Startup.cs')
| -rw-r--r-- | API/Startup.cs | 45 |
1 files changed, 1 insertions, 44 deletions
diff --git a/API/Startup.cs b/API/Startup.cs index de108a5..100e2e2 100644 --- a/API/Startup.cs +++ b/API/Startup.cs @@ -5,17 +5,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
-using Microsoft.OpenApi.Models;
-using Data.Models.Classes;
-using Data.Models.Options;
-using Microsoft.IdentityModel.Tokens;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using System.Text;
-using System.Threading.Tasks;
using API.Extensions;
-using API.Database;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.AspNetCore.Identity;
namespace API
{
@@ -33,41 +23,9 @@ namespace API {
services.AddControllers();
- services.AddSingleton<JWTOptions>(
- new JWTOptions(Configuration.GetSection("AppSettings").GetSection("Secret").Value));
-
- // Get key from appsettings.json
- var key = Encoding.ASCII.GetBytes(Configuration.GetSection("AppSettings").GetSection("Secret").Value);
- // Setup Jwt Authentication
- services.AddAuthentication(x =>
- {
- x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
- x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
- })
- .AddJwtBearer(x =>
- {
- x.Events = new JwtBearerEvents
- {
- OnTokenValidated = context =>
- {
- // TODO: add more authentication
- return Task.CompletedTask;
- }
- };
- x.RequireHttpsMetadata = false;
- x.SaveToken = true;
- x.TokenValidationParameters = new TokenValidationParameters
- {
- ValidateIssuerSigningKey = true,
- IssuerSigningKey = new SymmetricSecurityKey(key),
- ValidateIssuer = false,
- ValidateAudience = false
- };
- });
-
services.DatabaseConfiguration(Configuration);
services.SwaggerConfiguration();
- services.JWTConfiguration();
+ services.JWTConfiguration(Configuration);
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
}
@@ -88,7 +46,6 @@ namespace API }
app.UseDatabaseConfiguration();
- app.UseJWTConfiguration();
app.UseEndpoints(endpoints =>
{
|
