Skip to content

Commit fbc39b4

Browse files
committed
Merge develop into main
2 parents 1a77263 + 3671c32 commit fbc39b4

2 files changed

Lines changed: 10 additions & 22 deletions

File tree

‎wise-api/src/main/java/com/wisemapping/rest/UserController.java‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.springframework.validation.BindException;
4141
import org.springframework.web.bind.annotation.*;
4242

43-
import jakarta.servlet.http.HttpServletRequest;
4443
import jakarta.servlet.http.HttpServletResponse;
4544

4645
import java.util.Arrays;
@@ -80,13 +79,11 @@ public class UserController {
8079
private String domainBanExclusion;
8180

8281
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
83-
private static final String REAL_IP_ADDRESS_HEADER = "X-Real-IP";
84-
8582
@RequestMapping(method = RequestMethod.POST, value = "/", produces = {"application/json"})
8683
@ResponseStatus(value = HttpStatus.CREATED)
87-
public void registerUser(@RequestBody RestUserRegistration registration, @NotNull HttpServletRequest request,
84+
public void registerUser(@RequestBody RestUserRegistration registration,
8885
@NotNull HttpServletResponse response) throws WiseMappingException, BindException {
89-
logger.debug("Register new user:" + registration.getEmail());
86+
logger.debug("Register new user.");
9087
if (!registrationEnabled) {
9188
throw new WiseMappingException("Registration is disabled. You can enable it using app.registration.enabled");
9289
}
@@ -103,13 +100,7 @@ public void registerUser(@RequestBody RestUserRegistration registration, @NotNul
103100
throw new PasswordTooLongException();
104101
}
105102

106-
// If tomcat is behind a reverse proxy, ip needs to be found in other header.
107-
String remoteIp = request.getHeader(REAL_IP_ADDRESS_HEADER);
108-
if (remoteIp == null || remoteIp.isEmpty()) {
109-
remoteIp = request.getRemoteAddr();
110-
}
111-
logger.debug("Remote address" + remoteIp);
112-
verify(registration, remoteIp);
103+
verify(registration);
113104

114105
final Account user = new Account();
115106
user.setEmail(registration.getEmail().trim());
@@ -150,7 +141,7 @@ public void activateAccount(@RequestParam long code) throws WiseMappingException
150141
userService.activateAccount(code);
151142
}
152143

153-
private void verify(@NotNull final RestUserRegistration registration, @NotNull String remoteAddress)
144+
private void verify(@NotNull final RestUserRegistration registration)
154145
throws BindException {
155146

156147
final BindException errors = new RegistrationException(registration, "registration");
@@ -163,7 +154,7 @@ private void verify(@NotNull final RestUserRegistration registration, @NotNull S
163154
if (registrationCaptchaEnabled) {
164155
final String recaptcha = registration.getRecaptcha();
165156
if (recaptcha != null) {
166-
final String reCaptchaResponse = captchaService.verifyRecaptcha(remoteAddress, recaptcha);
157+
final String reCaptchaResponse = captchaService.verifyRecaptcha(recaptcha);
167158
if (reCaptchaResponse != null && !reCaptchaResponse.isEmpty()) {
168159
errors.rejectValue("recaptcha", reCaptchaResponse);
169160
}

‎wise-api/src/main/java/com/wisemapping/service/RecaptchaService.java‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,13 @@ public class RecaptchaService {
5555
private String recaptchaSecret;
5656

5757
@Nullable
58-
public String verifyRecaptcha(@NotNull String ip, @NotNull String recaptcha) {
58+
public String verifyRecaptcha(@NotNull String recaptcha) {
5959
String result = "";
60+
// Note: remoteip is intentionally omitted — it is optional in the Google reCAPTCHA API
61+
// and sending the user's IP to a third party (Google) without explicit consent would
62+
// violate GDPR Article 6 (no lawful basis) and Article 4(1) (IP = personal data).
6063
final String formBody = "secret=" + URLEncoder.encode(recaptchaSecret, StandardCharsets.UTF_8)
61-
+ "&response=" + URLEncoder.encode(recaptcha, StandardCharsets.UTF_8)
62-
+ "&remoteip=" + URLEncoder.encode(ip, StandardCharsets.UTF_8);
63-
64-
// Add logs ...
65-
logger.debug("Response from remoteip: " + ip);
66-
logger.debug("Response from recaptchaSecret: " + recaptchaSecret);
67-
logger.debug("Response from recaptcha: " + recaptcha);
64+
+ "&response=" + URLEncoder.encode(recaptcha, StandardCharsets.UTF_8);
6865

6966
try {
7067
final HttpRequest request = HttpRequest.newBuilder()

0 commit comments

Comments
 (0)