@@ -388,8 +388,7 @@ func (p *OAuthProxy) runValidatorsWithGracePeriod(session *sessions.SessionState
388388 return err
389389 }
390390 }
391- allowedGroups := p .upstreamConfig .AllowedGroups
392- logger .WithUser (session .Email ).WithAllowedGroups (allowedGroups ).Error (errors ,
391+ logger .WithUser (session .Email ).Error (errors ,
393392 "no longer authorized after validation period" )
394393 return ErrUserNotAuthorized
395394 }
@@ -610,7 +609,11 @@ func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) {
610609 logger .WithRemoteAddress (remoteAddr ).WithUser (session .Email ).WithInGroups (session .Groups ).Info (
611610 fmt .Sprintf ("oauth callback: user validated " ))
612611
613- //TODO: is there any verification we want to do on this?
612+ // We add the request host into the session to allow us to validate that each request has
613+ // been authorized for the upstream it's requesting.
614+ // e.g. if a request is authenticated while trying to reach 'foo' upstream, it should not
615+ // automatically be seen as authorized with 'bar' upstream. Each upstream may set different
616+ // validators, so the request should be reauthenticated.
614617 session .AuthorizedUpstream = req .Host
615618
616619 // We store the session in a cookie and redirect the user back to the application
@@ -807,6 +810,8 @@ func (p *OAuthProxy) Authenticate(rw http.ResponseWriter, req *http.Request) (er
807810 // - call up the provider chain to validate this user is still active and hasn't been de-authorized.
808811 // - run any defined email domain, email address, and email group validators against the session
809812
813+ //TODO: change this to match the RefreshSessionToken
814+ // (https://github.com/buzzfeed/sso/pull/275#discussion_r366448883)
810815 ok := p .provider .ValidateSessionToken (session )
811816 if ! ok {
812817 // This user is now no longer authorized, or we failed to
0 commit comments