synchro with main
This commit is contained in:
parent
26d36dee71
commit
d0e594c359
3 changed files with 22 additions and 5 deletions
18
src/Yavsc.Server/Helpers/ConfigHelpers.cs
Normal file
18
src/Yavsc.Server/Helpers/ConfigHelpers.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
namespace Yavsc.Server.Helpers;
|
||||||
|
|
||||||
|
public static class ConfigHelpers
|
||||||
|
{
|
||||||
|
public static void AddConfiguration(this WebApplicationBuilder builder, string appName )
|
||||||
|
{
|
||||||
|
var rootConfig = builder.Configuration
|
||||||
|
.AddJsonFile($"appsettings-{appName}.json", optional: false, reloadOnChange: false);
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(builder.Environment.EnvironmentName))
|
||||||
|
rootConfig.AddJsonFile($"appsettings-{appName}.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: false);
|
||||||
|
;
|
||||||
|
rootConfig.AddEnvironmentVariables();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,14 +12,12 @@
|
||||||
|
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Yavsc.Server.Helpers;
|
||||||
|
|
||||||
JwtSecurityTokenHandler.DefaultMapInboundClaims = true;
|
JwtSecurityTokenHandler.DefaultMapInboundClaims = true;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Configuration
|
builder.AddConfiguration("web");
|
||||||
.AddJsonFile("appsettings-web.json", optional: false, reloadOnChange: false)
|
|
||||||
.AddJsonFile($"appsettings-blogs.{builder.Environment.EnvironmentName}.json", optional: false, reloadOnChange: false)
|
|
||||||
.AddEnvironmentVariables();
|
|
||||||
var authSection = builder.Configuration.GetSection("Authentication");
|
var authSection = builder.Configuration.GetSection("Authentication");
|
||||||
|
|
||||||
var issuer = authSection.GetValue<String>("Issuer");
|
var issuer = authSection.GetValue<String>("Issuer");
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Yavsc.Abstract\Yavsc.Abstract.csproj" />
|
<ProjectReference Include="..\Yavsc.Abstract\Yavsc.Abstract.csproj" />
|
||||||
|
<ProjectReference Include="..\Yavsc.Abstract\Yavsc.Server.csproj" />
|
||||||
<PackageReference Include="IdentityModel.AspNetCore" />
|
<PackageReference Include="IdentityModel.AspNetCore" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -15,4 +16,4 @@
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue