Compare commits
No commits in common. "develop" and "v2024.11.8-74c2a2c" have entirely different histories.
develop
...
v2024.11.8
|
@ -21,9 +21,6 @@ func NewDefaultLayersConfig() LayersConfig {
|
||||||
Timeout: NewInterpolatedDuration(10 * time.Second),
|
Timeout: NewInterpolatedDuration(10 * time.Second),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Sessions: AuthnLayerSessionConfig{
|
|
||||||
TTL: NewInterpolatedDuration(time.Hour),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,11 +34,6 @@ type AuthnLayerConfig struct {
|
||||||
Debug InterpolatedBool `yaml:"debug"`
|
Debug InterpolatedBool `yaml:"debug"`
|
||||||
TemplateDir InterpolatedString `yaml:"templateDir"`
|
TemplateDir InterpolatedString `yaml:"templateDir"`
|
||||||
OIDC AuthnOIDCLayerConfig `yaml:"oidc"`
|
OIDC AuthnOIDCLayerConfig `yaml:"oidc"`
|
||||||
Sessions AuthnLayerSessionConfig `yaml:"sessions"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthnLayerSessionConfig struct {
|
|
||||||
TTL *InterpolatedDuration `yaml:"ttl"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthnOIDCLayerConfig struct {
|
type AuthnOIDCLayerConfig struct {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Session sessions.Options
|
Session sessions.Options
|
||||||
KeyPrefix string
|
KeyPrefix string
|
||||||
TTL time.Duration
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type OptionFunc func(opts *Options)
|
type OptionFunc func(opts *Options)
|
||||||
|
@ -26,7 +25,6 @@ func NewOptions(funcs ...OptionFunc) *Options {
|
||||||
SameSite: http.SameSiteDefaultMode,
|
SameSite: http.SameSiteDefaultMode,
|
||||||
},
|
},
|
||||||
KeyPrefix: "session:",
|
KeyPrefix: "session:",
|
||||||
TTL: time.Hour,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, fn := range funcs {
|
for _, fn := range funcs {
|
||||||
|
@ -47,9 +45,3 @@ func WithKeyPrefix(prefix string) OptionFunc {
|
||||||
opts.KeyPrefix = prefix
|
opts.KeyPrefix = prefix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithTTL(ttl time.Duration) OptionFunc {
|
|
||||||
return func(opts *Options) {
|
|
||||||
opts.TTL = ttl
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ type Store struct {
|
||||||
keyPrefix string
|
keyPrefix string
|
||||||
keyGen KeyGenFunc
|
keyGen KeyGenFunc
|
||||||
serializer SessionSerializer
|
serializer SessionSerializer
|
||||||
ttl time.Duration
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type KeyGenFunc func() (string, error)
|
type KeyGenFunc func() (string, error)
|
||||||
|
@ -44,7 +43,6 @@ func NewStore(adapter StoreAdapter, funcs ...OptionFunc) *Store {
|
||||||
keyPrefix: opts.KeyPrefix,
|
keyPrefix: opts.KeyPrefix,
|
||||||
keyGen: generateRandomKey,
|
keyGen: generateRandomKey,
|
||||||
serializer: GobSerializer{},
|
serializer: GobSerializer{},
|
||||||
ttl: opts.TTL,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rs
|
return rs
|
||||||
|
@ -64,14 +62,13 @@ func (s *Store) New(r *http.Request, name string) (*sessions.Session, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return session, nil
|
return session, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
session.ID = c.Value
|
session.ID = c.Value
|
||||||
|
|
||||||
err = s.load(r.Context(), session)
|
err = s.load(r.Context(), session)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
session.IsNew = false
|
session.IsNew = false
|
||||||
} else if !errors.Is(err, ErrNotFound) {
|
} else if !errors.Is(err, ErrNotFound) {
|
||||||
return session, errors.WithStack(err)
|
return nil, errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return session, nil
|
return session, nil
|
||||||
|
@ -123,12 +120,7 @@ func (s *Store) save(ctx context.Context, session *sessions.Session) error {
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ttl := time.Duration(session.Options.MaxAge) * time.Second
|
if err := s.adapter.Set(ctx, s.keyPrefix+session.ID, b, time.Duration(session.Options.MaxAge)*time.Second); err != nil {
|
||||||
if s.ttl < ttl || ttl == 0 {
|
|
||||||
ttl = s.ttl
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.adapter.Set(ctx, s.keyPrefix+session.ID, b, ttl); err != nil {
|
|
||||||
return errors.WithStack(err)
|
return errors.WithStack(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,11 +218,6 @@ layers:
|
||||||
authn:
|
authn:
|
||||||
# Répertoire contenant les templates
|
# Répertoire contenant les templates
|
||||||
templateDir: "/etc/bouncer/layers/authn/templates"
|
templateDir: "/etc/bouncer/layers/authn/templates"
|
||||||
# Configuration des sessions
|
|
||||||
sessions:
|
|
||||||
# Temps de persistence sans actualisation des sessions dans le store
|
|
||||||
# (prévalent sur le MaxAge de la session)
|
|
||||||
ttl: "1h"
|
|
||||||
|
|
||||||
# Configuration d'une série de proxy/layers
|
# Configuration d'une série de proxy/layers
|
||||||
# à créer par défaut par le serveur d'administration
|
# à créer par défaut par le serveur d'administration
|
||||||
|
|
Loading…
Reference in New Issue