Skip to content

Commit 5c2fe16

Browse files
committed
允许使用 JWT 本地 KEY
1 parent 1b2c38c commit 5c2fe16

15 files changed

Lines changed: 190 additions & 5 deletions

src/ZMap.Renderer.SkiaSharp/ZMap.Renderer.SkiaSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="../../package.props" />
44
<Import Project="../../version.props" />
55
<ItemGroup>
6-
<PackageReference Include="SkiaSharp" Version="3.116.1" />
6+
<PackageReference Include="SkiaSharp" Version="3.119.1" />
77
</ItemGroup>
88
<ItemGroup>
99
<ProjectReference Include="..\ZMap\ZMap.csproj" />

src/ZServer.API/Authentication/AllowAnonymousAuthorizationHandler.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44
namespace ZServer.API.Authentication;
55

66
// 可选:一个空的 IAuthorizationHandler,当禁用授权时用于满足依赖注入需求
7+
/// <summary>
8+
///
9+
/// </summary>
710
public class AllowAnonymousAuthorizationHandler : IAuthorizationHandler
811
{
12+
/// <summary>
13+
///
14+
/// </summary>
15+
/// <param name="context"></param>
16+
/// <returns></returns>
917
public Task HandleAsync(AuthorizationHandlerContext context)
1018
{
1119
// 直接让所有要求都通过

src/ZServer.API/Authentication/TokenAuthHandler.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@
99

1010
namespace ZServer.API.Authentication;
1111

12+
/// <summary>
13+
///
14+
/// </summary>
15+
/// <param name="options"></param>
16+
/// <param name="logger"></param>
17+
/// <param name="encoder"></param>
1218
public class TokenAuthHandler(IOptionsMonitor<TokenAuthOptions> options, ILoggerFactory logger, UrlEncoder encoder)
1319
: AuthenticationHandler<TokenAuthOptions>(options, logger, encoder)
1420
{
21+
/// <summary>
22+
///
23+
/// </summary>
24+
/// <returns></returns>
1525
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
1626
{
1727
if (Context.User.Identity is { IsAuthenticated: true })

src/ZServer.API/Authentication/TokenAuthOptions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,23 @@
33

44
namespace ZServer.API.Authentication;
55

6+
/// <summary>
7+
///
8+
/// </summary>
69
public class TokenAuthOptions : AuthenticationSchemeOptions
710
{
11+
/// <summary>
12+
///
13+
/// </summary>
814
public string AuthenticationType { get; set; } = "Token";
15+
16+
/// <summary>
17+
///
18+
/// </summary>
919
public HashSet<string> Tokens { get; set; } = new();
20+
21+
/// <summary>
22+
///
23+
/// </summary>
1024
public string ApiName { get; set; }
1125
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
namespace ZServer.API.Controllers;
22

3+
/// <summary>
4+
///
5+
/// </summary>
6+
/// <typeparam name="T"></typeparam>
37
public class ApiResult<T>
48
{
9+
/// <summary>
10+
///
11+
/// </summary>
512
public int Code { get; set; }
13+
14+
/// <summary>
15+
///
16+
/// </summary>
617
public bool Success { get; set; }
18+
19+
/// <summary>
20+
///
21+
/// </summary>
722
public T Data { get; set; }
23+
24+
/// <summary>
25+
///
26+
/// </summary>
827
public string Msg { get; set; }
928
}

src/ZServer.API/Controllers/TestController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ namespace ZServer.API.Controllers;
1010
[Route("[controller]")]
1111
public class TestController : ControllerBase
1212
{
13+
/// <summary>
14+
///
15+
/// </summary>
1316
[HttpGet]
1417
public async Task GetAsync()
1518
{

src/ZServer.API/Controllers/ToolControler.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@
1313

1414
namespace ZServer.API.Controllers;
1515

16+
/// <summary>
17+
///
18+
/// </summary>
19+
/// <param name="logger"></param>
20+
/// <param name="memoryCache"></param>
1621
[ApiController]
1722
[Route("api/v1.0/tools")]
1823
[Authorize]
1924
public class ToolController(ILogger<ToolController> logger, IMemoryCache memoryCache) : ControllerBase
2025
{
26+
/// <summary>
27+
///
28+
/// </summary>
2129
[HttpPost("crs_authority")]
2230
public async Task GetAuthority()
2331
{

src/ZServer.API/Filters/GlobalExceptionFilter.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@
44

55
namespace ZServer.API.Filters;
66

7+
/// <summary>
8+
///
9+
/// </summary>
10+
/// <param name="logger"></param>
711
public class GlobalExceptionFilter(ILogger<GlobalExceptionFilter> logger) : IExceptionFilter
812
{
13+
/// <summary>
14+
///
15+
/// </summary>
16+
/// <param name="context"></param>
917
public void OnException(ExceptionContext context)
1018
{
1119
context.HttpContext.Response.StatusCode = 500;

src/ZServer.API/HttpContextExtensions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,17 @@
99

1010
namespace ZServer.API;
1111

12+
/// <summary>
13+
///
14+
/// </summary>
1215
public static class HttpContextExtensions
1316
{
17+
/// <summary>
18+
///
19+
/// </summary>
20+
/// <param name="httpContext"></param>
21+
/// <param name="result"></param>
22+
/// <param name="infoFormat"></param>
1423
public static async Task WriteZServerResponseAsync(this HttpContext httpContext, ZServerResponse result,
1524
string infoFormat = "text/xml")
1625
{
@@ -44,6 +53,11 @@ public static async Task WriteZServerResponseAsync(this HttpContext httpContext,
4453
}
4554
}
4655

56+
/// <summary>
57+
///
58+
/// </summary>
59+
/// <param name="httpContext"></param>
60+
/// <param name="result"></param>
4761
public static async Task WriteAsync(this HttpContext httpContext, object result)
4862
{
4963
var options = httpContext.RequestServices.GetRequiredService<IOptions<JsonOptions>>().Value;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
namespace ZServer.API.Permission;
22

3+
/// <summary>
4+
///
5+
/// </summary>
36
public class PermissionOptions
47
{
8+
/// <summary>
9+
///
10+
/// </summary>
511
public string PermissionApi { get; set; }
612
}

0 commit comments

Comments
 (0)