Exemple #1
0
func discoverHandler(w http.ResponseWriter, r *http.Request) {
	if url, err := openid.RedirectUrl(r.FormValue("id"),
		"http://localhost:8080/openidcallback",
		""); err == nil {
		http.Redirect(w, r, url, 303)
	} else {
		log.Print(err)
	}
}
Exemple #2
0
func (oid *OpenID) OpRedirect(authorityURL string, w http.ResponseWriter, r *http.Request) error {
	// not present. redirect to authority for authentication
	cbuuid := uuid.NewRandom()

	// store the original user requested url
	originalUrl := fmt.Sprintf("https://%v%v", oid.responseHost(r), r.URL.String())
	oid.urlStore[cbuuid.String()] = originalUrl

	// now redirect to the authority
	fullURL := fmt.Sprintf("https://%v%v?cbuuid=%v", oid.responseHost(r), "/openidcallback", cbuuid)
	if redirectUrl, err := openid.RedirectUrl(authorityURL, fullURL, ""); err == nil {
		http.Redirect(w, r, redirectUrl, http.StatusSeeOther)
		return nil
	} else {
		return err
	}
}