A simple Laravel package that provides a middleware which will require users to confirm routes utilizing their pin for authentication.
- PHP 7.3+
- Laravel 8+
composer require ikechukwukalu/requirepin
php artisan vendor:publish --tag=rp-migrations
php artisan migrate
- Set
REDIS_CLIENT=predis
andQUEUE_CONNECTION=redis
within your.env
file. php artisan queue:work
- POST
api/change/pin
- POST
api/pin/required/{uuid}
- POST
change/pin
- POST
pin/required/{uuid}
- GET
change/pin
- GET
pin/required/{uuid?}
- To receive json response add
'Accept': 'application/json'
to your headers.
- First, it's like eating candy.
- The
require.pin
middlware should be added to a route or route group. - This middleware will arrest all incoming requests.
- A temporary URL (
pin/required/{uuid}
) is generated for a user to authenticate with the specified inputconfig(requirepin.input)
using their pin. - It either returns a
JSON
response with the generated URL or it redirects to a page where a user is required to authenticate the request by entering their pin into a form that will send a POST request to the generated URL when submitted. - To display return payload within blade:
@if (session('return_payload'))
@php
[$status, $status_code, $data] = json_decode(session('return_payload'), true);
@endphp
<div class="alert alert-{!! $status === 'fail' ? 'danger' : 'success' !!} m-5 text-center">
{!! $data['message'] !!}
</div>
@endif
_uuid
_pin
expires
signature
return_payload
pin_validation
php artisan vendor:publish --tag=rp-config
php artisan vendor:publish --tag=rp-lang
php artisan vendor:publish --tag=rp-views
The RP package is an open-sourced software licensed under the MIT license.