working #43
@@ -1,6 +1,5 @@
|
|||||||
Server:
|
Server:
|
||||||
Auth:
|
Auth:
|
||||||
Make sure autorenew works
|
|
||||||
Make sure rate limiting isnt being broken by cloudflare
|
Make sure rate limiting isnt being broken by cloudflare
|
||||||
|
|
||||||
Auth-Key-Value-Storage:
|
Auth-Key-Value-Storage:
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
namespace BoredCareers.Entities {
|
||||||
|
public class JWTRenewRequest {
|
||||||
|
public string JWT { get; set; } = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
-12
@@ -9,6 +9,7 @@ using Microsoft.IdentityModel.Tokens;
|
|||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using BoredCareers.Services.TimerService;
|
using BoredCareers.Services.TimerService;
|
||||||
|
using BoredCareers.Entities;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@@ -203,18 +204,18 @@ app.Use(async (context, next) =>{
|
|||||||
Claim? expClaim = user.FindFirst(JwtRegisteredClaimNames.Exp);
|
Claim? expClaim = user.FindFirst(JwtRegisteredClaimNames.Exp);
|
||||||
if (expClaim != null && long.TryParse(expClaim.Value, out long expUnix)) {
|
if (expClaim != null && long.TryParse(expClaim.Value, out long expUnix)) {
|
||||||
DateTimeOffset expTime = DateTimeOffset.FromUnixTimeSeconds(expUnix);
|
DateTimeOffset expTime = DateTimeOffset.FromUnixTimeSeconds(expUnix);
|
||||||
if ((expTime - DateTimeOffset.UtcNow) < TimeSpan.FromMinutes(2)) {
|
if ((expTime - DateTimeOffset.UtcNow) < TimeSpan.FromDays(3)) {
|
||||||
IHttpClientFactory clientFactory = context.RequestServices.GetRequiredService<IHttpClientFactory>();
|
using (HttpClient client = new HttpClient()) {
|
||||||
HttpClient client = clientFactory.CreateClient();
|
HttpResponseMessage response = await client.PostAsJsonAsync("https://auth.mistox.com/api/auth/renew", new JWTRenewRequest() { JWT = token });
|
||||||
HttpResponseMessage response = await client.PostAsync("https://auth.mistox.com/api/auth/renew", new StringContent(token));
|
if (response.IsSuccessStatusCode) {
|
||||||
if (response.IsSuccessStatusCode) {
|
string newJwt = await response.Content.ReadAsStringAsync();
|
||||||
string newJwt = await response.Content.ReadAsStringAsync();
|
context.Response.Cookies.Append("mistox_session", newJwt, new CookieOptions {
|
||||||
context.Response.Cookies.Append("mistox_session", newJwt, new CookieOptions {
|
HttpOnly = true,
|
||||||
HttpOnly = true,
|
Secure = true,
|
||||||
Secure = true,
|
SameSite = SameSiteMode.Strict,
|
||||||
SameSite = SameSiteMode.Strict,
|
Expires = DateTimeOffset.UtcNow.AddYears(3)
|
||||||
Expires = DateTimeOffset.UtcNow.AddYears(1)
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user