增加了SSO,现在token也可以从query的token读入

This commit is contained in:
2026-05-04 15:35:47 +08:00
parent e3fc7db01c
commit fc7b38ac4e
8 changed files with 73 additions and 41 deletions
+5 -6
View File
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using SimApi.Helpers;
@@ -11,11 +12,9 @@ public class SimApiAuthMiddleware(RequestDelegate next)
{
public Task Invoke(HttpContext httpContext, SimApiAuth auth)
{
string? token = null;
if (httpContext.Request.Headers.TryGetValue("Token", out var header))
{
token = header;
}
var token =
httpContext.Request.Headers["Token"].FirstOrDefault()
?? httpContext.Request.Query["token"].FirstOrDefault();
if (string.IsNullOrEmpty(token)) return next(httpContext);
var login = auth.GetLogin(token);