Skip to content

Commit ce7eba6

Browse files
authored
Add issued at leeway for verifying static credentials token (#11212)
1 parent 0f7cf47 commit ce7eba6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ydb/library/login/login.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,15 @@ TLoginProvider::TValidateTokenResponse TLoginProvider::ValidateToken(const TVali
389389
auto keyId = FromStringWithDefault<ui64>(decoded_token.get_key_id());
390390
const TKeyRecord* key = FindKey(keyId);
391391
if (key != nullptr) {
392+
static const size_t ISSUED_AT_LEEWAY_SEC = 2;
392393
auto verifier = jwt::verify()
393-
.allow_algorithm(jwt::algorithm::ps256(key->PublicKey));
394+
.allow_algorithm(jwt::algorithm::ps256(key->PublicKey))
395+
.issued_at_leeway(ISSUED_AT_LEEWAY_SEC);
394396
if (Audience) {
395397
// jwt.h require audience claim to be a set
396398
verifier.with_audience(std::set<std::string>{Audience});
397399
}
400+
398401
verifier.verify(decoded_token);
399402
response.User = decoded_token.get_subject();
400403
response.ExpiresAt = decoded_token.get_expires_at();

0 commit comments

Comments
 (0)