services/acl: check session token expiration epoch

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-03-29 14:38:01 +03:00 committed by Alex Vanin
parent 68903c9fd9
commit ff1912aa2a

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 {