| | |
| | | using System.Net; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core.Extensions; |
| | | |
| | | namespace WIDESEAWCS_Core.Middlewares |
| | | { |
| | |
| | | public async Task InvokeAsync(HttpContext context) |
| | | { |
| | | // 也可以根据是否是本地做判断 IsLocalRequest |
| | | if (context.Request.Path.Value.ToLower().Contains("index.html")) |
| | | if (context.Request.Path.Value?.ToLower().Contains("index.html") ?? false) |
| | | { |
| | | // 判断权限是否正确 |
| | | if (IsAuthorized(context)) |
| | |
| | | } |
| | | |
| | | // 无权限,跳转swagger登录页 |
| | | context.Response.Redirect("/swg-login.html"); |
| | | context.RedirectSwaggerLogin(); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | // 使用session模式 |
| | | // 可以使用其他的 |
| | | return context.Session.GetString("swagger-code") == "success"; |
| | | return context.IsSuccessSwagger(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | return true; |
| | | } |
| | | if (context.Connection.RemoteIpAddress.Equals(context.Connection.LocalIpAddress)) |
| | | if (context.Connection.RemoteIpAddress?.Equals(context.Connection.LocalIpAddress) ?? false) |
| | | { |
| | | return true; |
| | | } |