https://github.com/try0/wicket-honeypot
Adds honeypot field to the form.
https://github.com/try0/wicket-honeypot
form-validation honeypot security wicket
Last synced: 8 months ago
JSON representation
Adds honeypot field to the form.
- Host: GitHub
- URL: https://github.com/try0/wicket-honeypot
- Owner: try0
- License: apache-2.0
- Created: 2024-06-30T03:36:35.000Z (almost 2 years ago)
- Default Branch: wicket-10
- Last Pushed: 2024-07-06T15:37:46.000Z (almost 2 years ago)
- Last Synced: 2025-08-30T09:34:30.088Z (10 months ago)
- Topics: form-validation, honeypot, security, wicket
- Language: Java
- Homepage:
- Size: 172 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wicket-honeypot
Adds honeypot field to the form.
## Version
| Version | Wicket |
| ---- | ---- |
| [3.0.0](https://search.maven.org/artifact/jp.try0.wicket/wicket-honeypot-core/3.0.0/jar) | 10.x |
| [2.0.0](https://search.maven.org/artifact/jp.try0.wicket/wicket-honeypot-core/2.0.0/jar) | 9.x |
| [1.0.0](https://search.maven.org/artifact/jp.try0.wicket/wicket-honeypot-core/1.0.0/jar) | 8.x |
Wicket 10.x
```xml
jp.try0.wicket
wicket-honeypot-core
3.0.0
```
Wicket 9.x
```xml
jp.try0.wicket
wicket-honeypot-core
2.0.0
```
Wicket 8.x
```xml
jp.try0.wicket
wicket-honeypot-core
1.0.0
```
## Usage
```java
add(new Form("form") {
{
add(new HoneypotBehavior());
}
});
```
HoneypotBehavior uses JavaScript on the client side to add a honeypot field to the form. The added field is of type text and will be hidden using styles.
```html
```
The field addition process can be executed with a delay.
For example, this code determines that requests made within two seconds of the screen being displayed are bot actions.
```java
add(new Form("form") {
{
int delayMs = 2000;
add(new HoneypotBehavior(delayMs));
}
});
```
To display a message and request form resubmission when a user action is mistakenly identified as a bot action, please override the onError method.
```java
add(new Form("form") {
{
int delayMs = 2000;
add(new HoneypotBehavior(delayMs) {
@Override
protected void onError(Form> form) {
form.error(HomePage.this.getString("honeypot_error_message")); // TODO your prop key
}
});
}
});
```
With other configs.
```java
add(new Form("form") {
{
// custom config
HoneypotBehaviorConfig config = new HoneypotBehaviorConfig();
// the field addition process can be executed with a delay.
// default: 0
config.setDelay(1500);
// honeypot field autocomplete attr.
// default: one-time-code
config.setAutocomplete("one-time-code");
// block submit on the client.
// default: false
config.setBlockSubmit(true);
// If none of [keydown, mousemove, touchstart, touchmove, scroll] events are detected, assume the user is a bot.
// default: false
config.setDetectHumanActivity(true);
add(new HoneypotBehavior(config));
}
});
```