To secure your AEM Sling servlet from fraudulent attempts (e.g., direct access via API clients like Postman), you can implement the following measures:
1. Enable CSRF Protection: Use AEM's built-in CSRF protection to prevent unauthorized requests.
2. Validate Referrer & Origin Headers: Ensure that requests to the servlet only come from trusted sources (your website).
3. Restrict Access to Logged-in Users: Limit access to the servlet by requiring the user to be logged in (if appropriate).
4. Use CAPTCHA for Bot Prevention: Implement CAPTCHA validation, ideally both on the client and server side, to prevent automated submissions.
5. Implement Rate Limiting: Use rate limiting at the Dispatcher level or via CDN to limit excessive requests.
6. Whitelist Allowed Domains or IPs: Restrict access by whitelisting trusted domains or IPs to prevent external API clients from making requests.
7. Use JWT/OAuth Authentication: Secure your API with JWT or OAuth to ensure that only authorized users or services can invoke the servlet.
By combining these methods, especially CSRF protection, CAPTCHA, and referrer validation, you can greatly reduce the risk of fraudulent access.