фича: автообновление сессии
This commit is contained in:
@@ -6,7 +6,10 @@
|
||||
namespace http::auth::jwt {
|
||||
extern std::string secretKey;
|
||||
|
||||
constexpr const char* EMPTY_AUTH_COOKIE = "auth=;Path=/; Max-Age=86400; HttpOnly; SameSite=Lax";;
|
||||
constexpr const char* EMPTY_AUTH_COOKIE = "auth=;Path=/; Max-Age=86400; HttpOnly; SameSite=Lax";
|
||||
|
||||
constexpr int64_t SESSION_LIVE_MS = 24 * 60 * 60 * 1000; // 24 часа
|
||||
constexpr int64_t SESSION_UPDATE_THRESHOLD = 10 * 60 * 1000; // 10 минут
|
||||
|
||||
void generateSecretKey();
|
||||
|
||||
@@ -17,6 +20,7 @@ namespace http::auth::jwt {
|
||||
*/
|
||||
class Jwt {
|
||||
std::string payload;
|
||||
int64_t lastUpdate = 0;
|
||||
std::string signature;
|
||||
public:
|
||||
static Jwt fromCookies(const std::string& cookie);
|
||||
@@ -26,7 +30,9 @@ namespace http::auth::jwt {
|
||||
|
||||
std::string getUsername();
|
||||
|
||||
std::string asCookie();
|
||||
std::string asCookie(bool isSecure = false);
|
||||
|
||||
bool needUpdate() const;
|
||||
|
||||
~Jwt();
|
||||
};
|
||||
|
Reference in New Issue
Block a user