Compare commits
2 Commits
ba1f54b21c
...
6ff39aa3d4
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ff39aa3d4 | |||
| 4702e73b5a |
@@ -0,0 +1,17 @@
|
||||
using Atomx.Admin.Middlewares;
|
||||
|
||||
namespace Atomx.Admin.Extensions
|
||||
{
|
||||
public static class SecurityHeadersExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 安全头
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseSecurityHeaders(this IApplicationBuilder builder)
|
||||
{
|
||||
return builder.UseMiddleware<SecurityHeadersMiddleware>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,12 @@ namespace Atomx.Admin.Services
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
int GetTimeZone();
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户代理信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string GetUserAgent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -102,5 +108,10 @@ namespace Atomx.Admin.Services
|
||||
var timeZone = _httpContextAccessor.HttpContext?.User?.Claims?.SingleOrDefault(p => p.Type == "TimeZone")?.Value ?? "0";
|
||||
return timeZone.ToInt();
|
||||
}
|
||||
|
||||
public string GetUserAgent()
|
||||
{
|
||||
return _httpContextAccessor.HttpContext?.Request.Headers["User-Agent"].FirstOrDefault() ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user