Replace captcha package with own implementation
This commit is contained in:
30
app/Http/Controllers/Auth/CaptchaController.php
Normal file
30
app/Http/Controllers/Auth/CaptchaController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use AltchaOrg\Altcha\Algorithm\Pbkdf2;
|
||||
use AltchaOrg\Altcha\Altcha;
|
||||
use AltchaOrg\Altcha\CreateChallengeOptions;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class CaptchaController extends Controller
|
||||
{
|
||||
public function create(): array
|
||||
{
|
||||
$pbkdf2 = new Pbkdf2;
|
||||
|
||||
$altcha = new Altcha(
|
||||
hmacSignatureSecret: config('captcha.hmac_key'),
|
||||
);
|
||||
|
||||
// Create challenge
|
||||
$challenge = $altcha->createChallenge(new CreateChallengeOptions(
|
||||
algorithm: $pbkdf2,
|
||||
cost: 5000,
|
||||
counter: random_int(5000, 10000),
|
||||
expiresAt: time() + 600,
|
||||
));
|
||||
|
||||
return get_object_vars($challenge);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user