services/acl: check session token expiration epoch

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
remotes/fyrchik/morph-cache
Evgenii Stratonikov 2022-03-29 14:38:01 +03:00 committed by Alex Vanin
parent 68903c9fd9
commit ff1912aa2a
1 changed files with 11 additions and 0 deletions

View File

@ -417,6 +417,17 @@ func (b Service) findRequestInfo(
return info, errors.New("missing owner in container descriptor")
}
if req.token != nil && req.token.Exp() != 0 {
currentEpoch, err := b.nm.Epoch()
if err != nil {
return info, errors.New("can't fetch current epoch")
}
if req.token.Exp() < currentEpoch {
return info, fmt.Errorf("%w: token has expired (current epoch: %d, expired at %d)",
ErrMalformedRequest, currentEpoch, req.token.Exp())
}
}
// find request role and key
res, err := b.c.classify(req, cid, cnr)
if err != nil {