mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-03 19:32:48 +02:00
refactor session state
This commit is contained in:
parent
3225d3b032
commit
315ee2610f
2 changed files with 118 additions and 59 deletions
|
@ -6,7 +6,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
|
@ -45,8 +44,7 @@ type Authorize struct {
|
|||
tracerProvider oteltrace.TracerProvider
|
||||
tracer oteltrace.Tracer
|
||||
|
||||
activeStreamsMu sync.Mutex
|
||||
activeStreams []chan error
|
||||
activeStreams ActiveStreams
|
||||
}
|
||||
|
||||
// New validates and creates a new Authorize service from a set of config options.
|
||||
|
@ -59,7 +57,9 @@ func New(ctx context.Context, cfg *config.Config) (*Authorize, error) {
|
|||
globalCache: storage.NewGlobalCache(time.Minute),
|
||||
tracerProvider: tracerProvider,
|
||||
tracer: tracer,
|
||||
activeStreams: []chan error{},
|
||||
activeStreams: ActiveStreams{
|
||||
streamsById: map[uint64]*StreamState{},
|
||||
},
|
||||
}
|
||||
a.accessTracker = NewAccessTracker(a, accessTrackerMaxSize, accessTrackerDebouncePeriod)
|
||||
|
||||
|
@ -167,15 +167,6 @@ func newPolicyEvaluator(
|
|||
|
||||
// OnConfigChange updates internal structures based on config.Options
|
||||
func (a *Authorize) OnConfigChange(ctx context.Context, cfg *config.Config) {
|
||||
a.activeStreamsMu.Lock()
|
||||
// demo code
|
||||
if cfg.Options.Routes[0].AllowAnyAuthenticatedUser == false {
|
||||
for _, s := range a.activeStreams {
|
||||
s <- fmt.Errorf("no longer authorized")
|
||||
}
|
||||
clear(a.activeStreams)
|
||||
}
|
||||
a.activeStreamsMu.Unlock()
|
||||
currentState := a.state.Load()
|
||||
a.currentConfig.Store(cfg)
|
||||
if newState, err := newAuthorizeStateFromConfig(ctx, a.tracerProvider, cfg, a.store, currentState.evaluator); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue