Skip to content

Commit

Permalink
Fix #1636: For API /auth/combinded assert credentialName
Browse files Browse the repository at this point in the history
  • Loading branch information
jandusil committed Apr 30, 2024
1 parent 6b35a97 commit b4b3a38
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/Next-Step-Server-REST-API-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -8837,6 +8837,8 @@ The list of expected status codes:
}
```

**The `credentialName` parameter is optional and should not be used or it has to be the same as used for OTP generation.**

#### Response 200

- Headers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
@Data
public class CombinedAuthenticationRequest {

@NotBlank
@Size(min = 2, max = 256)
private String credentialName;
@NotBlank
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,10 @@ public CombinedAuthenticationResponse authenticateCombined(CombinedAuthenticatio
final IdGeneratorService idGeneratorService = serviceCatalogue.getIdGeneratorService();

final OtpEntity otp = otpService.findOtp(request.getOtpId(), request.getOperationId());
if (!request.getCredentialName().equals(otp.getCredentialDefinition().getName())) {
throw new InvalidRequestException("Mismatched credentialName for OTP: " + otp.getOtpId() + "'. The credentialName must match the one used for OTP generation.");
}

if (otp.getOtpDefinition().isDataAdapterProxyEnabled()) {
logger.info("Combined authentication proxied through Data Adapter, OTP ID: {}", request.getOtpId());
return authenticateCombinedCustom(otp.getCredentialDefinition(), otp.getOtpId(), request.getOtpValue(), request.getCredentialValue(), otp.getOperation().getOperationId(), otp.getUserId(), request.getAuthMethod());
Expand Down

0 comments on commit b4b3a38

Please sign in to comment.