mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-24 12:08:19 +02:00
core/identity: add enabler (#5084)
* core/identity: add disabler * enable by default * add name * rename to enabler, use mutex instead of goroutine * rename method, add comments
This commit is contained in:
parent
a518435c17
commit
99a5dbd65b
4 changed files with 190 additions and 4 deletions
|
@ -19,6 +19,7 @@ type config struct {
|
|||
sessionRefreshCoolOffDuration time.Duration
|
||||
now func() time.Time
|
||||
eventMgr *events.Manager
|
||||
enabled bool
|
||||
}
|
||||
|
||||
func newConfig(options ...Option) *config {
|
||||
|
@ -26,6 +27,7 @@ func newConfig(options ...Option) *config {
|
|||
WithSessionRefreshGracePeriod(defaultSessionRefreshGracePeriod)(cfg)
|
||||
WithSessionRefreshCoolOffDuration(defaultSessionRefreshCoolOffDuration)(cfg)
|
||||
WithNow(time.Now)(cfg)
|
||||
WithEnabled(true)(cfg)
|
||||
for _, option := range options {
|
||||
option(cfg)
|
||||
}
|
||||
|
@ -72,7 +74,14 @@ func WithNow(now func() time.Time) Option {
|
|||
|
||||
// WithEventManager passes an event manager to record events
|
||||
func WithEventManager(mgr *events.Manager) Option {
|
||||
return func(c *config) {
|
||||
c.eventMgr = mgr
|
||||
return func(cfg *config) {
|
||||
cfg.eventMgr = mgr
|
||||
}
|
||||
}
|
||||
|
||||
// WithEnabled sets the enabled option in the config.
|
||||
func WithEnabled(enabled bool) Option {
|
||||
return func(cfg *config) {
|
||||
cfg.enabled = enabled
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue