Skip to content

Commit

Permalink
fix: fixes for cancel support (#3735)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuriy Movchan <Yuriy.Movchan@gmail.com>
  • Loading branch information
yuremm and yurem committed Jan 31, 2023
1 parent 0237f44 commit 3e64530
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public ObjectNode options(JsonNode params) {
public ObjectNode verify(JsonNode params) {
log.debug("authenticateResponse {}", params);

boolean superGluu = commonVerifiers.hasSuperGluu(params);
boolean oneStep = commonVerifiers.isSuperGluuOneStepMode(params);
boolean cancelRequest = commonVerifiers.isSuperGluuOneStepMode(params);

Expand All @@ -232,7 +233,9 @@ public ObjectNode verify(JsonNode params) {

// Verify client data
JsonNode clientDataJSONNode = commonVerifiers.verifyClientJSON(responseNode);
commonVerifiers.verifyClientJSONTypeIsGet(clientDataJSONNode);
if (!superGluu) {
commonVerifiers.verifyClientJSONTypeIsGet(clientDataJSONNode);
}

// Get challenge
String challenge = commonVerifiers.getChallenge(clientDataJSONNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public ObjectNode options(JsonNode params) {
public ObjectNode verify(JsonNode params) {
log.debug("Attestation verify {}", params);

boolean superGluu = commonVerifiers.hasSuperGluu(params);
boolean oneStep = commonVerifiers.isSuperGluuOneStepMode(params);
boolean cancelRequest = commonVerifiers.isSuperGluuOneStepMode(params);

Expand All @@ -206,7 +207,9 @@ public ObjectNode verify(JsonNode params) {

// Verify client data
JsonNode clientDataJSONNode = commonVerifiers.verifyClientJSON(responseNode);
commonVerifiers.verifyClientJSONTypeIsCreate(clientDataJSONNode);
if (!superGluu) {
commonVerifiers.verifyClientJSONTypeIsCreate(clientDataJSONNode);
}

// Get challenge
String challenge = commonVerifiers.getChallenge(clientDataJSONNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ public void process(String base64AuthenticatorData, String signature, String cli
userVerificationVerifier.verifyUserPresent(authData);

String clientDataJsonString = new String(base64Service.urlDecode(clientDataJson), StandardCharsets.UTF_8);
// Update to conform Super Gluu
clientDataJsonString = clientDataJsonString.replace("type", "typ").replaceAll("webauthn.get", "navigator.id.getAssertion");

byte[] clientDataHash = DigestUtils.getSha256Digest().digest(clientDataJsonString.getBytes(StandardCharsets.UTF_8));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public JsonNode finishAuthentication(String userName, String authenticateRespons

// Convert clientData node to new format
ObjectNode clientData = dataMapperService.createObjectNode();
clientData.put("type", "webauthn.get");
clientData.put("type", authenticateResponse.getClientData().getTyp());
clientData.put("challenge", authenticateResponse.getClientData().getChallenge());
clientData.put("origin", authenticateResponse.getClientData().getOrigin());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public JsonNode finishRegistration(String userName, String registerResponseStrin
ObjectNode clientData = dataMapperService.createObjectNode();
clientData.put("challenge", registerResponse.getClientData().getChallenge());
clientData.put("origin", registerResponse.getClientData().getOrigin());
clientData.put("type", "webauthn.create");
clientData.put("type", registerResponse.getClientData().getTyp());
response.put("clientDataJSON", base64Service.urlEncodeToString(clientData.toString().getBytes(Charset.forName("UTF-8"))));

// Store cancel type
Expand Down

0 comments on commit 3e64530

Please sign in to comment.