Upgrade to .NET Core 3.1, update libs

This commit is contained in:
Trojaner 2020-10-08 06:55:07 +03:00
parent ce7dfb3a9e
commit f7d3b72ab9
2 changed files with 32 additions and 20 deletions

View file

@ -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<AppInMemoryDbContext>(options =>
services.AddDbContext<AppInMemoryDbContext>(options =>
options.UseInMemoryDatabase("default"));
services.AddIdentity<IdentityUser, IdentityRole>(options =>
@ -45,18 +45,17 @@ namespace SteamOpenIdConnectProvider
services.AddIdentityServer(options =>
{
options.UserInteraction.LoginUrl = "/ExternalLogin";
options.PublicOrigin = Configuration["Hosting:PublicOrigin"];
})
.AddAspNetIdentity<IdentityUser>()
.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<IProfileService, SteamProfileService>();
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 =>

View file

@ -1,27 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<UserSecretsId>9f8cb9ce-f696-422f-901a-563af9413684</UserSecretsId>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AspNet.Security.OpenId.Steam" Version="2.1.0" />
<PackageReference Include="AspNet.Security.OpenId.Steam" Version="3.1.0" />
<PackageReference Include="AspNet.Security.OpenIdConnect.Server" Version="2.0.0" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.0.0" />
<PackageReference Include="IdentityServer4" Version="3.0.1" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="3.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="3.1.2" />
<PackageReference Include="IdentityServer4" Version="4.1.1" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="4.1.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
<PackageReference Include="Serilog" Version="2.8.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
</ItemGroup>