mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-03 03:12:50 +02:00
fix databroker restart versioning, handle missing sessions (#1145)
* fix databroker restart versioning, handle missing sessions * send empty server version to detect change * only rebuild if there are updated records
This commit is contained in:
parent
a5e8abd6af
commit
557aef2a33
7 changed files with 53 additions and 62 deletions
|
@ -49,19 +49,6 @@ func (a *Authorize) Check(ctx context.Context, in *envoy_service_auth_v2.CheckRe
|
|||
rawJWT, _ := loadRawSession(hreq, a.currentOptions.Load(), a.currentEncoder.Load())
|
||||
sessionState, _ := loadSession(a.currentEncoder.Load(), rawJWT)
|
||||
|
||||
// only accept sessions whose databroker server versions match
|
||||
if sessionState != nil {
|
||||
a.dataBrokerDataLock.RLock()
|
||||
if a.dataBrokerSessionServerVersion != sessionState.Version.String() {
|
||||
log.Warn().
|
||||
Str("server_version", a.dataBrokerSessionServerVersion).
|
||||
Str("session_version", sessionState.Version.String()).
|
||||
Msg("clearing session due to invalid version")
|
||||
sessionState = nil
|
||||
}
|
||||
a.dataBrokerDataLock.RUnlock()
|
||||
}
|
||||
|
||||
if err := a.forceSync(ctx, sessionState); err != nil {
|
||||
log.Warn().Err(err).Msg("clearing session due to force sync failed")
|
||||
sessionState = nil
|
||||
|
@ -98,7 +85,7 @@ func (a *Authorize) forceSync(ctx context.Context, ss *sessions.State) error {
|
|||
}
|
||||
s := a.forceSyncSession(ctx, ss.ID)
|
||||
if s == nil {
|
||||
return nil
|
||||
return errors.New("session not found")
|
||||
}
|
||||
if s.DeletedAt != nil {
|
||||
return errors.New("session was deleted")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue