forked from TrueCloudLab/frostfs-api-go
session: support the expiration of private tokens
All sessions in NeoFS has limited in epochs lifetime. There is a need to limit the lifetime of private session tokens. This commmit: * extends PrivateToken interface with Expired method; * defines EpochLifetimeStore interface with RemoveExpired method and embeds it to PrivateTokenStore interface; * adds epoch value parameter to private token constructor.
This commit is contained in:
parent
8cbdb9183f
commit
4fa7360cd1
5 changed files with 116 additions and 4 deletions
|
@ -45,3 +45,20 @@ func (s *mapTokenStore) Fetch(id TokenID) (PrivateToken, error) {
|
|||
|
||||
return t, nil
|
||||
}
|
||||
|
||||
// RemoveExpired removes all the map elements that are expired in the passed epoch.
|
||||
//
|
||||
// Resulting error is always nil.
|
||||
func (s *mapTokenStore) RemoveExpired(epoch uint64) error {
|
||||
s.Lock()
|
||||
|
||||
for key, token := range s.tokens {
|
||||
if token.Expired(epoch) {
|
||||
delete(s.tokens, key)
|
||||
}
|
||||
}
|
||||
|
||||
s.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue