// Authenticate authenticates a request by checking for a session cookie, and validating its expiration,
// clearing the session cookie if it's invalid and returning an error if necessary..
Authenticate authenticates a request by checking for a session cookie, and validating its expiration,
clearing the session cookie if it's invalid and returning an error if necessary
// Authenticate authenticates a request by checking for a session cookie and validating its expiration // clearing the session cookie if it ' s invalid and returning an error if necessary ..
func (p *Proxy) Authenticate(w http.ResponseWriter, r *http.Request) (err error) {
	session, err := p.sessionStore.LoadSession(r)
	if err != nil {
		p.sessionStore.ClearSession(w, r)
		return err
	}
	if session.RefreshPeriodExpired() {
		session, err = p.AuthenticateClient.Refresh(r.Context(), session)
		if err != nil {
			p.sessionStore.ClearSession(w, r)
			log.FromRequest(r).Warn().Err(err).Msg("proxy: refresh failed")
			return err
		}
	}
	err = p.sessionStore.SaveSession(w, r, session)
	if err != nil {
		p.sessionStore.ClearSession(w, r)
		return err
	}
	r.Header.Set(HeaderUserID, session.User)
	r.Header.Set(HeaderEmail, session.Email)
	r.Header.Set(HeaderGroups, strings.Join(session.Groups, ","))
	return nil
}
func ( p * Proxy ) Authenticate ( w http . ResponseWriter , r * http . Request ) ( err error ) { session , err := p . sessionStore . LoadSession ( r ) if err != nil { p . sessionStore . ClearSession ( w , r ) return err } if session . RefreshPeriodExpired ( ) { session , err = p . AuthenticateClient . Refresh ( r . Context ( ) , session ) if err != nil { p . sessionStore . ClearSession ( w , r ) log . FromRequest ( r ) . Warn ( ) . Err ( err ) . Msg ( " " ) return err } } err = p . sessionStore . SaveSession ( w , r , session ) if err != nil { p . sessionStore . ClearSession ( w , r ) return err } r . Header . Set ( HeaderUserID , session . User ) r . Header . Set ( HeaderEmail , session . Email ) r . Header . Set ( HeaderGroups , strings . Join ( session . Groups , " " ) ) return nil }
Authenticate authenticates a request by checking for a session cookie, and validating its expiration,
clearing the session cookie if it's invalid and returning an error if necessary
Authenticate authenticates a request by checking for a session cookie and validating its expiration clearing the session cookie if it ' s invalid and returning an error if necessary
// AccessToken's usually expire after 60 or so minutes. If offline_access scope is set, a // refresh token (which doesn't change) can be used to request a new access-token. If access // is revoked by identity provider, or no refresh token is set, request will return an error // pass user & user-email details to client applications // This user has been OK'd. Allow the request!