// OAuthStart begins the authenticate flow, encrypting the redirect url
// in a request to the provider's sign in endpoint.
OAuthStart begins the authenticate flow, encrypting the redirect url
in a request to the provider's sign in endpoint.
// OAuthStart begins the authenticate flow encrypting the redirect url // in a request to the provider ' s sign in endpoint .
func (p *Proxy) OAuthStart(w http.ResponseWriter, r *http.Request) {
	requestURI := r.URL.String()
	callbackURL := p.GetRedirectURL(r.Host)
	state := &StateParameter{
		SessionID:   fmt.Sprintf("%x", cryptutil.GenerateKey()), 
		RedirectURI: requestURI,                                 
	}
	encryptedCSRF, err := p.cipher.Marshal(state)
	if err != nil {
		log.FromRequest(r).Error().Err(err).Msg("proxy: failed to marshal csrf")
		httputil.ErrorResponse(w, r, err.Error(), http.StatusInternalServerError)
		return
	}
	p.csrfStore.SetCSRF(w, r, encryptedCSRF)
	encryptedState, err := p.cipher.Marshal(state)
	if err != nil {
		log.FromRequest(r).Error().Err(err).Msg("proxy: failed to encrypt cookie")
		httputil.ErrorResponse(w, r, err.Error(), http.StatusInternalServerError)
		return
	}
	signinURL := p.GetSignInURL(p.AuthenticateURL, callbackURL, encryptedState)
	log.FromRequest(r).Info().Str("SigninURL", signinURL.String()).Msg("proxy: oauth start")
	http.Redirect(w, r, signinURL.String(), http.StatusFound)
}
func ( p * Proxy ) OAuthStart ( w http . ResponseWriter , r * http . Request ) { requestURI := r . URL . String ( ) callbackURL := p . GetRedirectURL ( r . Host ) state := & StateParameter { SessionID : fmt . Sprintf ( " " , cryptutil . GenerateKey ( ) ) , RedirectURI : requestURI , } encryptedCSRF , err := p . cipher . Marshal ( state ) if err != nil { log . FromRequest ( r ) . Error ( ) . Err ( err ) . Msg ( " " ) httputil . ErrorResponse ( w , r , err . Error ( ) , http . StatusInternalServerError ) return } p . csrfStore . SetCSRF ( w , r , encryptedCSRF ) encryptedState , err := p . cipher . Marshal ( state ) if err != nil { log . FromRequest ( r ) . Error ( ) . Err ( err ) . Msg ( " " ) httputil . ErrorResponse ( w , r , err . Error ( ) , http . StatusInternalServerError ) return } signinURL := p . GetSignInURL ( p . AuthenticateURL , callbackURL , encryptedState ) log . FromRequest ( r ) . Info ( ) . Str ( " " , signinURL . String ( ) ) . Msg ( " " ) http . Redirect ( w , r , signinURL . String ( ) , http . StatusFound ) }
OAuthStart begins the authenticate flow, encrypting the redirect url
in a request to the provider's sign in endpoint.
OAuthStart begins the authenticate flow encrypting the redirect url in a request to the provider ' s sign in endpoint .
// state prevents cross site forgery and maintain state across the client and server // nonce // where to redirect the user back to // we encrypt this value to be opaque the browser cookie // this value will be unique since we always use a randomized nonce as part of marshaling // we encrypt this value to be opaque the uri query value // this value will be unique since we always use a randomized nonce as part of marshaling // redirect the user to the authenticate provider along with the encrypted state which // contains a redirect uri pointing back to the proxy