make sure user has agreed before any subsequent actions

This commit is contained in:
Roland Shoemaker 2015-05-20 12:58:14 -07:00
parent 870f02917c
commit 0f4f17e82b
2 changed files with 19 additions and 3 deletions

View File

@ -311,6 +311,10 @@ func (wfe *WebFrontEndImpl) NewAuthorization(response http.ResponseWriter, reque
}
return
}
if currReg.Agreement == "" {
wfe.sendError(response, "Must agree to subscriber agreement before any further actions", nil, http.StatusForbidden)
return
}
var init core.Authorization
if err = json.Unmarshal(body, &init); err != nil {
@ -353,11 +357,15 @@ func (wfe *WebFrontEndImpl) RevokeCertificate(response http.ResponseWriter, requ
return
}
body, requestKey, _, err := wfe.verifyPOST(request, false)
body, requestKey, reg, err := wfe.verifyPOST(request, false)
if err != nil {
wfe.sendError(response, "Unable to read/verify body", err, http.StatusBadRequest)
return
}
if reg.Agreement == "" {
wfe.sendError(response, "Must agree to subscriber agreement before any further actions", nil, http.StatusForbidden)
return
}
type RevokeRequest struct {
CertificateDER core.JsonBuffer `json:"certificate"`
@ -438,6 +446,10 @@ func (wfe *WebFrontEndImpl) NewCertificate(response http.ResponseWriter, request
}
return
}
if reg.Agreement == "" {
wfe.sendError(response, "Must agree to subscriber agreement before any further actions", nil, http.StatusForbidden)
return
}
var init core.CertificateRequest
if err = json.Unmarshal(body, &init); err != nil {
@ -516,6 +528,10 @@ func (wfe *WebFrontEndImpl) Challenge(authz core.Authorization, response http.Re
}
return
}
if currReg.Agreement == "" {
wfe.sendError(response, "Must agree to subscriber agreement before any further actions", nil, http.StatusForbidden)
return
}
var challengeResponse core.Challenge
if err = json.Unmarshal(body, &challengeResponse); err != nil {

View File

@ -92,7 +92,7 @@ func (sa *MockSA) GetRegistration(id int64) (core.Registration, error) {
var parsedKey jose.JsonWebKey
parsedKey.UnmarshalJSON(keyJSON)
return core.Registration{Key: parsedKey}, nil
return core.Registration{Key: parsedKey, Agreement: "yup"}, nil
}
func (sa *MockSA) GetRegistrationByKey(jwk jose.JsonWebKey) (core.Registration, error) {
@ -111,7 +111,7 @@ func (sa *MockSA) GetRegistrationByKey(jwk jose.JsonWebKey) (core.Registration,
}
// Return a fake registration
return core.Registration{}, nil
return core.Registration{Agreement: "yup"}, nil
}
func (sa *MockSA) GetAuthorization(string) (core.Authorization, error) {