Skip to content

Commit 4e4f9b1

Browse files
devondragonclaude
andcommitted
Improve documentation for configuration properties
- Add missing properties to README configuration example: - url, connect-timeout, read-timeout - Filter properties (login.submissionPath, login.redirectUrl, token.parameterName) - Update additional-spring-configuration-metadata.json with all 11 properties for better IDE autocomplete support - Fix README code example to use constructor injection (@requiredargsconstructor) instead of field injection (@Autowired) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 666be83 commit 4e4f9b1

2 files changed

Lines changed: 47 additions & 9 deletions

File tree

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,20 @@ ds:
7171
turnstile:
7272
sitekey: # Turnstile Site Key
7373
secret: # Turnstile Secret
74+
url: https://challenges.cloudflare.com/turnstile/v0/siteverify # API endpoint (optional, this is the default)
75+
connect-timeout: 5 # Connection timeout in seconds (optional, default: 5)
76+
read-timeout: 10 # Read timeout in seconds (optional, default: 10)
7477
# Optional monitoring configuration
7578
metrics:
7679
enabled: true
7780
health-check-enabled: true
7881
error-threshold: 10
82+
# Optional filter configuration (only needed if using TurnstileCaptchaFilter)
83+
login:
84+
submissionPath: /login # Path to intercept (default: /login)
85+
redirectUrl: /login?error=captcha # Redirect URL on failure
86+
token:
87+
parameterName: cf-turnstile-response # Token parameter name (default)
7988
```
8089
8190
@@ -128,23 +137,21 @@ Here's a complete example:
128137

129138
```java
130139
import com.digitalsanctuary.cf.turnstile.service.TurnstileValidationService;
131-
import org.springframework.beans.factory.annotation.Autowired;
132140
import org.springframework.stereotype.Controller;
133141
import org.springframework.ui.Model;
134142
import org.springframework.web.bind.annotation.PostMapping;
135143
import org.springframework.web.bind.annotation.RequestParam;
136144
import jakarta.servlet.http.HttpServletRequest;
145+
import lombok.RequiredArgsConstructor;
137146
import lombok.extern.slf4j.Slf4j;
138147

139148
@Slf4j
140149
@Controller
150+
@RequiredArgsConstructor
141151
public class LoginController {
142152

143-
@Autowired
144-
private TurnstileValidationService turnstileValidationService;
145-
146-
@Autowired
147-
private UserService userService;
153+
private final TurnstileValidationService turnstileValidationService;
154+
private final UserService userService;
148155

149156
@PostMapping("/login")
150157
public String login(Model model,

src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,30 @@
33
{
44
"name": "ds.cf.turnstile.url",
55
"type": "java.lang.String",
6-
"description": "Cloudflare Turnstile API Endpoint URL'"
6+
"description": "Cloudflare Turnstile API endpoint URL",
7+
"defaultValue": "https://challenges.cloudflare.com/turnstile/v0/siteverify"
78
},
89
{
910
"name": "ds.cf.turnstile.secret",
1011
"type": "java.lang.String",
11-
"description": "Your Cloudflare Turnstile API Secret"
12+
"description": "Your Cloudflare Turnstile API Secret (required)"
1213
},
1314
{
1415
"name": "ds.cf.turnstile.sitekey",
1516
"type": "java.lang.String",
16-
"description": "Your Cloudflare Turnstile Site Key"
17+
"description": "Your Cloudflare Turnstile Site Key (required)"
18+
},
19+
{
20+
"name": "ds.cf.turnstile.connect-timeout",
21+
"type": "java.lang.Integer",
22+
"description": "Connection timeout in seconds for Turnstile API calls",
23+
"defaultValue": 5
24+
},
25+
{
26+
"name": "ds.cf.turnstile.read-timeout",
27+
"type": "java.lang.Integer",
28+
"description": "Read timeout in seconds for Turnstile API calls",
29+
"defaultValue": 10
1730
},
1831
{
1932
"name": "ds.cf.turnstile.metrics.enabled",
@@ -32,6 +45,24 @@
3245
"type": "java.lang.Integer",
3346
"description": "Threshold for error rate percentage that triggers health status degradation",
3447
"defaultValue": 10
48+
},
49+
{
50+
"name": "ds.cf.turnstile.login.submission-path",
51+
"type": "java.lang.String",
52+
"description": "Path to intercept for login submissions when using TurnstileCaptchaFilter",
53+
"defaultValue": "/login"
54+
},
55+
{
56+
"name": "ds.cf.turnstile.login.redirect-url",
57+
"type": "java.lang.String",
58+
"description": "URL to redirect to when captcha validation fails",
59+
"defaultValue": "/login?error=captcha"
60+
},
61+
{
62+
"name": "ds.cf.turnstile.token.parameter-name",
63+
"type": "java.lang.String",
64+
"description": "Name of the request parameter containing the Turnstile token",
65+
"defaultValue": "cf-turnstile-response"
3566
}
3667
]
3768
}

0 commit comments

Comments
 (0)