Skip to content

You can easily configure method-level security in your Controller through annotations.

License

Notifications You must be signed in to change notification settings

easypeel-security/easypeel-method-security

Repository files navigation

Easypeel Method Security

Build Status Coverage Status Maven Central JavaDoc License

You can easily configure method-level security in your RestController through annotations.

Since it's still in beta, the software currently has limited features. If you're interested in following the project's progress, please press the ⭐ button to stay updated.

Requirements

⚠️ Requires Spring Boot 3.x

Dependencies

implementation 'org.easypeelsecurity:easypeel-method-security:0.0.4'
annotationProcessor 'org.easypeelsecurity:easypeel-method-security:0.0.4'

Quick Start

1. MethodBan

The @MethodBan enables you to implement a simple Rate Limit within your controller. If you need more details, please check the details page.

1.1. Only IP based ban :

@GetMapping("/")
@MethodBan(times = 3, seconds = 10, banSeconds = 1000) // this
public String hello() {
  return "Hello World!";
}

Once a same IP accesses an API 3 times within 10 seconds, they are prevented from accessing the same API for 1000 banSeconds.

1.2. IP & User based ban :

@PostMapping("/")
@MethodBan(times = 3, seconds = 10, banSeconds = 1000,
    banMessage = "You're writing too fast. Please try again later.",
    additionalFilter = @ParameterFilter(name = "enterpriseUser")) // this
public void createJobPosting(
    @CurrentUser EnterpriseUserAccount enterpriseUser) {
  // ... 

}

Once a same IP and User Credential accesses an API 3 times within 10 seconds, they are prevented from accessing the same API for 1000 banSeconds.

2. Another Feature is Coming Soon!

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. More information can be found in the CONTRIBUTING.md file.

License

This project is licensed under the terms of the apache 2.0 license.