WebauthnAttestedRequest.php 874 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Http\Requests;
  3. use Illuminate\Support\Facades\Gate;
  4. use Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable;
  5. use Laragear\WebAuthn\Http\Requests\AttestedRequest;
  6. use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
  7. class WebauthnAttestedRequest extends AttestedRequest
  8. {
  9. /**
  10. * Handle a failed authorization attempt.
  11. *
  12. * @return void
  13. *
  14. * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
  15. */
  16. protected function failedAuthorization()
  17. {
  18. throw new AccessDeniedHttpException(__('errors.unsupported_with_sso_only'));
  19. }
  20. /**
  21. * Determine if the user is authorized to make this request.
  22. */
  23. public function authorize(?WebAuthnAuthenticatable $user): bool
  24. {
  25. return (bool) $user && Gate::allows('manage-webauthn-credentials');
  26. }
  27. }