Skip to content

Commit 6f8f294

Browse files
fix: base64url-encoded nonce
verification API expects the nonce to be b64url-encoded Signed-off-by: Thomas Fossati <[email protected]>
1 parent 9141ad3 commit 6f8f294

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

verification/challengeresponse.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func (cfg ChallengeResponseConfig) newSessionRequest() (*http.Response, error) {
283283
// nonceSize=32)
284284
q := req.URL.Query()
285285
if len(cfg.Nonce) > 0 {
286-
q.Set("nonce", base64.StdEncoding.EncodeToString(cfg.Nonce))
286+
q.Set("nonce", base64.URLEncoding.EncodeToString(cfg.Nonce))
287287
} else if cfg.NonceSz > 0 {
288288
q.Set("nonceSize", fmt.Sprint(cfg.NonceSz))
289289
}

verification/challengeresponse_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func TestChallengeResponseConfig_NewSession_ok(t *testing.T) {
137137

138138
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
139139
assert.Equal(t, http.MethodPost, r.Method)
140-
assert.Equal(t, "3q2+7w==", r.URL.Query().Get("nonce"))
140+
assert.Equal(t, "3q2-7w==", r.URL.Query().Get("nonce"))
141141
assert.Equal(t, "application/vnd.veraison.challenge-response-session+json", r.Header.Get("Accept"))
142142

143143
w.Header().Set("Location", expectedSessionURI)
@@ -251,7 +251,7 @@ func TestChallengeResponseConfig_NewSession_relative_location_ok(t *testing.T) {
251251
relativeSessionURI := testRelSessionURI
252252
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
253253
assert.Equal(t, http.MethodPost, r.Method)
254-
assert.Equal(t, "3q2+7w==", r.URL.Query().Get("nonce"))
254+
assert.Equal(t, "3q2-7w==", r.URL.Query().Get("nonce"))
255255
assert.Equal(t, "application/vnd.veraison.challenge-response-session+json", r.Header.Get("Accept"))
256256

257257
w.Header().Set("Location", relativeSessionURI)
@@ -821,7 +821,7 @@ func synthesizeSession(mt string, ev []byte) []string {
821821
}
822822
}`,
823823
}
824-
evs := base64.StdEncoding.EncodeToString(ev)
824+
evs := base64.URLEncoding.EncodeToString(ev)
825825
s[1] = fmt.Sprintf(s[1], mt, evs)
826826
s[2] = fmt.Sprintf(s[2], evs)
827827
return s

0 commit comments

Comments
 (0)