[#1229] util: Fix session token expiration check
All checks were successful
Vulncheck / Vulncheck (pull_request) Successful in 3m31s
DCO action / DCO (pull_request) Successful in 3m19s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m16s
Build / Build Components (1.22) (pull_request) Successful in 5m7s
Build / Build Components (1.21) (pull_request) Successful in 5m13s
Tests and linters / Staticcheck (pull_request) Successful in 7m12s
Tests and linters / gopls check (pull_request) Successful in 7m13s
Tests and linters / Lint (pull_request) Successful in 8m6s
Tests and linters / Tests (1.21) (pull_request) Successful in 10m17s
Tests and linters / Tests with -race (pull_request) Successful in 10m18s
Tests and linters / Tests (1.22) (pull_request) Successful in 10m35s

* Make session token expired at `current_epoch + 1` but
  not at `current_epoch` when it's still valid.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-07-05 11:50:11 +03:00
parent 4c7ff159ec
commit 433550514d

View file

@ -67,7 +67,7 @@ func (s *KeyStorage) GetKey(info *SessionInfo) (*ecdsa.PrivateKey, error) {
pToken := s.tokenStore.Get(info.Owner, binID)
if pToken != nil {
if pToken.ExpiredAt() <= s.networkState.CurrentEpoch() {
if pToken.ExpiredAt() < s.networkState.CurrentEpoch() {
return nil, new(apistatus.SessionTokenExpired)
}
return pToken.SessionKey(), nil