From d3b026d9da5fe75185d5641852c71a390d67aa61 Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 8 Jan 2020 16:53:05 -0500 Subject: [PATCH] updated references and project to latest versions --- api/Program.cs | 21 --------------------- api/Startup.cs | 7 ++----- api/api.csproj | 6 +++--- auth/Startup.cs | 4 ++-- auth/auth.csproj | 8 ++++---- 5 files changed, 11 insertions(+), 35 deletions(-) diff --git a/api/Program.cs b/api/Program.cs index 73ebcdc..1cfbf09 100644 --- a/api/Program.cs +++ b/api/Program.cs @@ -28,27 +28,6 @@ private static string HostUrl public static void Main(string[] args) { DotEnv.Config(throwOnError: false); - - var bytes = System.IO.File.ReadAllBytes("/Users/plasne/Documents/keys/cert.pfx"); - var certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(bytes, "Vampyr0000!!!!"); - var signingCredentials = new Microsoft.IdentityModel.Tokens.X509SigningCredentials(certificate, Microsoft.IdentityModel.Tokens.SecurityAlgorithms.RsaSha256); - var claims = new System.Collections.Generic.List(); - claims.Add(new System.Security.Claims.Claim("sub", "663c73c9-47e1-4a11-9a74-620d7e291c45")); - claims.Add(new System.Security.Claims.Claim("jti", System.Guid.NewGuid().ToString())); - var jwt = new System.IdentityModel.Tokens.Jwt.JwtSecurityToken( - issuer: "663c73c9-47e1-4a11-9a74-620d7e291c45", - audience: "https://login.microsoftonline.com/a5f2ede2-d815-4bca-a46d-b007a3e1571a/oauth2/token", - claims: claims, - notBefore: DateTime.UtcNow, - expires: DateTime.UtcNow.AddMinutes(60), - signingCredentials: signingCredentials); - var handler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler(); - Console.WriteLine("================="); - var encoded = handler.WriteToken(jwt); - Console.WriteLine(encoded); - Console.WriteLine("================="); - - CreateWebHostBuilder(args).Build().Run(); } diff --git a/api/Startup.cs b/api/Startup.cs index 3c7b78a..6dfe52f 100644 --- a/api/Startup.cs +++ b/api/Startup.cs @@ -5,9 +5,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -310,8 +308,7 @@ public void ConfigureServices(IServiceCollection services) // setup CORS policy services.AddCors(options => { - options.AddPolicy("origins", - builder => + options.AddDefaultPolicy(builder => { builder.WithOrigins(TokenValidator.AllowedOrigins) .AllowAnyHeader() @@ -328,7 +325,7 @@ public void ConfigureServices(IServiceCollection services) public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseRouting(); - app.UseCors("origins"); + app.UseCors(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => diff --git a/api/api.csproj b/api/api.csproj index 412c009..bd91f42 100644 --- a/api/api.csproj +++ b/api/api.csproj @@ -1,12 +1,12 @@ - netcoreapp3.0 + netcoreapp3.1 InProcess - - + + \ No newline at end of file diff --git a/auth/Startup.cs b/auth/Startup.cs index 211ede4..d18b01a 100644 --- a/auth/Startup.cs +++ b/auth/Startup.cs @@ -78,8 +78,7 @@ public void ConfigureServices(IServiceCollection services) // setup CORS policy services.AddCors(options => { - options.AddPolicy("origins", - builder => + options.AddDefaultPolicy(builder => { builder.WithOrigins(TokenIssuer.AllowedOrigins) .AllowAnyHeader() @@ -96,6 +95,7 @@ public void ConfigureServices(IServiceCollection services) public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseRouting(); + app.UseCors(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); diff --git a/auth/auth.csproj b/auth/auth.csproj index bb5d8d7..47221b1 100644 --- a/auth/auth.csproj +++ b/auth/auth.csproj @@ -1,12 +1,12 @@ - netcoreapp3.0 + netcoreapp3.1 InProcess - - - + + + \ No newline at end of file