From f7d3b72ab9b4633087989794635898e87e3acd1f Mon Sep 17 00:00:00 2001 From: Trojaner Date: Thu, 8 Oct 2020 06:55:07 +0300 Subject: [PATCH] Upgrade to .NET Core 3.1, update libs --- src/Startup.cs | 27 +++++++++++++++++++-------- src/SteamOpenIdConnectProvider.csproj | 25 +++++++++++++------------ 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/Startup.cs b/src/Startup.cs index 44ee044..0f8dfef 100644 --- a/src/Startup.cs +++ b/src/Startup.cs @@ -1,5 +1,6 @@ using System; using System.Net.Http; +using IdentityServer4.Extensions; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; @@ -24,15 +25,14 @@ namespace SteamOpenIdConnectProvider public IConfiguration Configuration { get; } - // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers() .AddNewtonsoftJson() .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); - + services.AddSingleton(Configuration); - services.AddDbContext(options => + services.AddDbContext(options => options.UseInMemoryDatabase("default")); services.AddIdentity(options => @@ -45,18 +45,17 @@ namespace SteamOpenIdConnectProvider services.AddIdentityServer(options => { options.UserInteraction.LoginUrl = "/ExternalLogin"; - options.PublicOrigin = Configuration["Hosting:PublicOrigin"]; }) .AddAspNetIdentity() .AddInMemoryClients(IdentityServerConfig.GetClients( - Configuration["OpenID:ClientID"], - Configuration["OpenID:ClientSecret"], - Configuration["OpenID:RedirectUri"], + Configuration["OpenID:ClientID"], + Configuration["OpenID:ClientSecret"], + Configuration["OpenID:RedirectUri"], Configuration["OpenID:PostLogoutRedirectUri"])) .AddInMemoryPersistedGrants() .AddDeveloperSigningCredential(true) .AddInMemoryIdentityResources(IdentityServerConfig.GetIdentityResources()); - + services.AddHttpClient(); services.AddAuthentication() @@ -86,6 +85,18 @@ namespace SteamOpenIdConnectProvider app.UsePathBase(Configuration["Hosting:PathBase"]); } + app.UseCookiePolicy(); + app.Use(async (ctx, next) => + { + var origin = Configuration["Hosting:PublicOrigin"]; + if (!string.IsNullOrEmpty(origin)) + { + ctx.SetIdentityServerOrigin(origin); + } + + await next(); + }); + app.UseRouting(); app.UseIdentityServer(); app.UseEndpoints(endpoints => diff --git a/src/SteamOpenIdConnectProvider.csproj b/src/SteamOpenIdConnectProvider.csproj index f5cfd22..1b3243f 100644 --- a/src/SteamOpenIdConnectProvider.csproj +++ b/src/SteamOpenIdConnectProvider.csproj @@ -1,27 +1,28 @@  - netcoreapp3.0 + netcoreapp3.1 InProcess 9f8cb9ce-f696-422f-901a-563af9413684 + 8 - + - - - + + + - - + + - - - - - + + + + +