From ce7eba68928d6320832bada32acfc4881491c911 Mon Sep 17 00:00:00 2001 From: Andrey Molotkov Date: Wed, 13 Nov 2024 18:05:13 +0300 Subject: [PATCH] Add issued at leeway for verifying static credentials token (#11212) --- ydb/library/login/login.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ydb/library/login/login.cpp b/ydb/library/login/login.cpp index 403e2502f0ed..4c225e8f4691 100644 --- a/ydb/library/login/login.cpp +++ b/ydb/library/login/login.cpp @@ -389,12 +389,15 @@ TLoginProvider::TValidateTokenResponse TLoginProvider::ValidateToken(const TVali auto keyId = FromStringWithDefault(decoded_token.get_key_id()); const TKeyRecord* key = FindKey(keyId); if (key != nullptr) { + static const size_t ISSUED_AT_LEEWAY_SEC = 2; auto verifier = jwt::verify() - .allow_algorithm(jwt::algorithm::ps256(key->PublicKey)); + .allow_algorithm(jwt::algorithm::ps256(key->PublicKey)) + .issued_at_leeway(ISSUED_AT_LEEWAY_SEC); if (Audience) { // jwt.h require audience claim to be a set verifier.with_audience(std::set{Audience}); } + verifier.verify(decoded_token); response.User = decoded_token.get_subject(); response.ExpiresAt = decoded_token.get_expires_at();