对接fake simple admin completed
This commit is contained in:
parent
4c200cd1ff
commit
0ab0ed9adc
6
Directory.Build.props
Normal file
6
Directory.Build.props
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- All Fake packages -->
|
||||||
|
<FakePackageVersion>8.0.0</FakePackageVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@ -18,6 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solution
|
|||||||
NuGet.Config = NuGet.Config
|
NuGet.Config = NuGet.Config
|
||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
.editorconfig = .editorconfig
|
.editorconfig = .editorconfig
|
||||||
|
Directory.Build.props = Directory.Build.props
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
|
|
||||||
namespace TrackCenter.Api;
|
|
||||||
|
|
||||||
public class JWTEncryption
|
|
||||||
{
|
|
||||||
/// <summary>生成Token验证参数</summary>
|
|
||||||
/// <param name="jwtSettings"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static TokenValidationParameters CreateTokenValidationParameters(
|
|
||||||
JWTSettingsOptions jwtSettings)
|
|
||||||
{
|
|
||||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.SecretKey));
|
|
||||||
|
|
||||||
return new TokenValidationParameters()
|
|
||||||
{
|
|
||||||
ValidateIssuer = true,
|
|
||||||
ValidateAudience = true,
|
|
||||||
ValidateLifetime = true,
|
|
||||||
ValidateIssuerSigningKey = true,
|
|
||||||
ValidIssuer = jwtSettings.Issuer,
|
|
||||||
ValidAudience = jwtSettings.Audience,
|
|
||||||
IssuerSigningKey = key,
|
|
||||||
ClockSkew = TimeSpan.FromSeconds(jwtSettings.ClockSkewMinutes),
|
|
||||||
// 验证过期时间
|
|
||||||
RequireExpirationTime = true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
namespace TrackCenter.Api;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>Jwt 配置</summary>
|
|
||||||
public sealed class JWTSettingsOptions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 配置节名称
|
|
||||||
/// </summary>
|
|
||||||
public static string SectionName = "JwtSettings";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 密钥(至少32位字符)
|
|
||||||
/// </summary>
|
|
||||||
public string SecretKey { get; set; } = "YourSuperSecretKeyThatIsAtLeast32CharactersLong!";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 签发者
|
|
||||||
/// </summary>
|
|
||||||
public string Issuer { get; set; } = "SimpleAdmin";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 受众
|
|
||||||
/// </summary>
|
|
||||||
public string Audience { get; set; } = "SimpleAdminClient";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Access Token 过期时间(分钟)
|
|
||||||
/// </summary>
|
|
||||||
public int ExpiryInMinutes { get; set; } = 60;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Refresh Token 过期时间(天)
|
|
||||||
/// </summary>
|
|
||||||
public int RefreshExpiryInDays { get; set; } = 7;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 时钟偏移(分钟),用于处理服务器时间差异
|
|
||||||
/// </summary>
|
|
||||||
public int ClockSkewMinutes { get; set; } = 5;
|
|
||||||
}
|
|
||||||
@ -18,7 +18,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\TrackCenter.Application\TrackCenter.Application.csproj" />
|
<ProjectReference Include="..\TrackCenter.Application\TrackCenter.Application.csproj" />
|
||||||
<ProjectReference Include="..\TrackCenter.Repository\TrackCenter.Repository.csproj" />
|
<ProjectReference Include="..\TrackCenter.Repository\TrackCenter.Repository.csproj" />
|
||||||
<PackageReference Include="Fake.Autofac" Version="8.0.0-preview19" />
|
<PackageReference Include="Fake.Autofac" Version="8.0.0" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
|
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
|
|||||||
@ -142,16 +142,7 @@ public class TrackCenterApiModule : FakeModule
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
services.AddFakeJwtAuthentication();
|
||||||
services.AddAuthentication(options =>
|
|
||||||
{
|
|
||||||
options.DefaultAuthenticateScheme = "Bearer";
|
|
||||||
options.DefaultChallengeScheme = "Bearer";
|
|
||||||
}).AddJwtBearer(options =>
|
|
||||||
{
|
|
||||||
var jwtSettings = configuration.GetSection("JWTSettings").Get<JWTSettingsOptions>();
|
|
||||||
options.TokenValidationParameters = JWTEncryption.CreateTokenValidationParameters(jwtSettings);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 添加授权服务
|
// 添加授权服务
|
||||||
services.AddAuthorization();
|
services.AddAuthorization();
|
||||||
|
|||||||
@ -8,9 +8,9 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Fake.AspNetCore" Version="8.0.0-preview19" />
|
<PackageReference Include="Fake.AspNetCore" Version="8.0.0" />
|
||||||
<PackageReference Include="Fake.EventBus.RabbitMQ" Version="8.0.0-preview19" />
|
<PackageReference Include="Fake.EventBus.RabbitMQ" Version="8.0.0" />
|
||||||
<PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="8.0.0-preview19" />
|
<PackageReference Include="Fake.ObjectMapping.AutoMapper" Version="8.0.0" />
|
||||||
|
|
||||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
|
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
|
||||||
<PackageReference Include="Confluent.Kafka" Version="2.10.0" />
|
<PackageReference Include="Confluent.Kafka" Version="2.10.0" />
|
||||||
|
|||||||
@ -9,11 +9,11 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="NEST" Version="7.17.5" />
|
<PackageReference Include="NEST" Version="7.17.5" />
|
||||||
<PackageReference Include="Fake.SqlSugarCore" Version="8.0.0-preview19" />
|
<PackageReference Include="Fake.SqlSugarCore" Version="8.0.0" />
|
||||||
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Serilog" Version="4.3.0" />
|
<PackageReference Include="Serilog" Version="4.3.0" />
|
||||||
<PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.0-preview19" />
|
<PackageReference Include="Fake.DomainDrivenDesign" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user