mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 09:19:39 +02:00
authorize: track session and service account access date (#3220)
* session: add accessed at date
* authorize: track session and service account access times
* Revert "databroker: add support for field masks on Put (#3210)"
This reverts commit 2dc778035d
.
* add test
* fix data race in test
* add deadline for update
* track dropped accesses
This commit is contained in:
parent
a243056cfa
commit
36f73fa6c7
14 changed files with 474 additions and 67 deletions
2
internal/sets/sets.go
Normal file
2
internal/sets/sets.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
// Package sets contains set data structures.
|
||||
package sets
|
36
internal/sets/size_limited.go
Normal file
36
internal/sets/size_limited.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package sets
|
||||
|
||||
// A SizeLimitedStringSet is a StringSet which is limited to a given size. Once
|
||||
// the capacity is reached an element will be removed at random.
|
||||
type SizeLimitedStringSet struct {
|
||||
m map[string]struct{}
|
||||
capacity int
|
||||
}
|
||||
|
||||
// NewSizeLimitedStringSet create a new SizeLimitedStringSet.
|
||||
func NewSizeLimitedStringSet(capacity int) *SizeLimitedStringSet {
|
||||
return &SizeLimitedStringSet{
|
||||
m: make(map[string]struct{}),
|
||||
capacity: capacity,
|
||||
}
|
||||
}
|
||||
|
||||
// Add adds an element to the set.
|
||||
func (s *SizeLimitedStringSet) Add(element string) {
|
||||
s.m[element] = struct{}{}
|
||||
for len(s.m) > s.capacity {
|
||||
for k := range s.m {
|
||||
delete(s.m, k)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ForEach iterates over all the elements in the set.
|
||||
func (s *SizeLimitedStringSet) ForEach(callback func(element string) bool) {
|
||||
for k := range s.m {
|
||||
if !callback(k) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue