Move refreshing code to block acquiring cookied session
This commit is contained in:
parent
48dbb391bc
commit
2f6dcf3b5f
@ -725,15 +725,14 @@ func (p *OAuthProxy) getAuthenticatedSession(rw http.ResponseWriter, req *http.R
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Printf("Error loading cookied session: %s", err)
|
logger.Printf("Error loading cookied session: %s", err)
|
||||||
}
|
}
|
||||||
if session != nil && session.Age() > p.CookieRefresh && p.CookieRefresh != time.Duration(0) {
|
|
||||||
|
if session != nil {
|
||||||
|
if session.Age() > p.CookieRefresh && p.CookieRefresh != time.Duration(0) {
|
||||||
logger.Printf("Refreshing %s old session cookie for %s (refresh after %s)", session.Age(), session, p.CookieRefresh)
|
logger.Printf("Refreshing %s old session cookie for %s (refresh after %s)", session.Age(), session, p.CookieRefresh)
|
||||||
saveSession = true
|
saveSession = true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if session != nil {
|
if ok, err := p.provider.RefreshSessionIfNeeded(session); err != nil {
|
||||||
var ok bool
|
|
||||||
if ok, err = p.provider.RefreshSessionIfNeeded(session); err != nil {
|
|
||||||
logger.Printf("%s removing session. error refreshing access token %s %s", remoteAddr, err, session)
|
logger.Printf("%s removing session. error refreshing access token %s %s", remoteAddr, err, session)
|
||||||
clearSession = true
|
clearSession = true
|
||||||
session = nil
|
session = nil
|
||||||
@ -742,6 +741,7 @@ func (p *OAuthProxy) getAuthenticatedSession(rw http.ResponseWriter, req *http.R
|
|||||||
revalidated = true
|
revalidated = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if session != nil && session.IsExpired() {
|
if session != nil && session.IsExpired() {
|
||||||
logger.Printf("Removing session: token expired %s", session)
|
logger.Printf("Removing session: token expired %s", session)
|
||||||
|
Loading…
Reference in New Issue
Block a user