Ejemplo n.º 1
0
func signRequest(w http.ResponseWriter, r *http.Request) {
	if registration == nil {
		http.Error(w, "registration missing", http.StatusBadRequest)
		return
	}

	c, err := u2f.NewChallenge(appID, trustedFacets)
	if err != nil {
		log.Printf("u2f.NewChallenge error: %v", err)
		http.Error(w, "error", http.StatusInternalServerError)
		return
	}
	challenge = c

	//reg := registration
	//yuval
	//var reg u2f.Registration
	// if err := reg.UnmarshalBinary(registration); err != nil {
	// 	log.Printf("reg.UnmarshalBinary error: %v", err)
	// 	http.Error(w, "error", http.StatusInternalServerError)
	// 	return
	// }
	req := *c.SignRequest(registration)

	log.Printf("authenitcateRequest: %+v", req)
	json.NewEncoder(w).Encode(req)
}
Ejemplo n.º 2
0
func registerRequest(w http.ResponseWriter, r *http.Request) {
	c, err := u2f.NewChallenge(appID, trustedFacets)
	if err != nil {
		log.Printf("u2f.NewChallenge error: %v", err)
		http.Error(w, "error", http.StatusInternalServerError)
		return
	}
	challenge = c
	req := c.RegisterRequest()

	log.Printf("registerRequest: %+v", req)
	json.NewEncoder(w).Encode(req)
}