mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-01-24 12:03:17 +00:00
🔒 Add manual hex validation for LNURL-Auth parameters k1 and key with improved test coverage
This commit is contained in:
@@ -24,11 +24,24 @@ final class LnurlAuthController extends Controller
|
||||
{
|
||||
try {
|
||||
$validated = $request->validate([
|
||||
'k1' => ['required', 'string', 'hex', 'size:128'],
|
||||
'k1' => ['required', 'string', 'size:64'],
|
||||
'sig' => ['required', 'string'],
|
||||
'key' => ['required', 'string', 'hex', 'min:64', 'max:66'],
|
||||
'key' => ['required', 'string', 'min:64', 'max:66'],
|
||||
]);
|
||||
|
||||
// Validate hex format manually
|
||||
if (! ctype_xdigit($validated['k1'])) {
|
||||
throw ValidationException::withMessages([
|
||||
'k1' => ['The k1 field must be a valid hexadecimal string.'],
|
||||
]);
|
||||
}
|
||||
|
||||
if (! ctype_xdigit($validated['key'])) {
|
||||
throw ValidationException::withMessages([
|
||||
'key' => ['The key field must be a valid hexadecimal string.'],
|
||||
]);
|
||||
}
|
||||
|
||||
$isVerified = lnurl\auth($validated['k1'], $validated['sig'], $validated['key']);
|
||||
|
||||
if (! $isVerified) {
|
||||
|
||||
Reference in New Issue
Block a user