I recently started designing my own Web-API and my current goal is to make it possible to register guest user with his phone number, but there is a requirement: my database must not contain phone number duplicates. So I decided that I need a service for validating this case. That's where I felt a little bit confused.
Let's suppose I have one REST-service which checks whether entered phone number exists in system.
It consumes phone number (like +7-913-XXX-XX-XX
) and produces boolean value depending on phone number presence/absence in database.
If I implemented this logic it'd be really naive, so I'd be able to send as many requests to this service as I want and find out real numbers related to this system. As a conclusion, data will be compromised some day.
The way of blocking particular IP-address (due to high RPS from one machine) obviously does not seem to be a best solution because there are ways to make it through different IPs.
My questions are following:
- Have I missed any concept in my goal (wrong direction or smth)? How should I check phone number in another way if it's required to check it in database?
- If it's okay, is it even possible to avoid kind of this brute forcing so my data (not only phone numbers but any personal data in general) will be kept safe and sound?
- If not, are there any general ways to make brute forcing not so easy? (except the way above)
- How do Java-developers deal with it? Can
Spring
-framework help in this case, by any chance?