Swedish BankId integration for Laravel 8
patrikgrinsvall/laravel-bankid is a Laravel package for swedish bankid integration for laravel 8.
It currently has 0 GitHub stars and 71 downloads on Packagist (latest version v0.2.0).
Install it with composer require patrikgrinsvall/laravel-bankid.
Discover more Laravel packages by patrikgrinsvall
or browse all Laravel packages to compare alternatives.
Last updated
While this package is free to use, you can hire help of integrating it, contact [email protected]
You will need laravel 8 to use route facade but it might work with earlier versions when using middleware. Livewire is a required dependency so it will be installed. I think however its possible to quite easy call the service from another controller action and it will work quite well.
Anyway, there are a plenthora of improvements to be made to this project but it is used in production for atleast one company. PRs are very welcome.
Composer:
composer require patrikgrinsvall/laravel-bankid
php artisan vendor:publish --provider="Patrikgrinsvall\LaravelBankid\LaravelBankidServiceProvider"
app/config/bankid.php for info on how to add your own certificates.Patrikgrinsvall\LaravelBankid\BankidServiceProvider in config/app.phpThere are a few different ways to use this package
// You can change the route prefix '/bankid' to whatever you want, for example /login.
// This is then the entrypoint for where users should be sent to start authentication.
// This line of code should be placed in routes.
Route::LaravelBankid('/bankid');
use Patrikgrinsvall\LaravelBankid\BankidFacade;
...
Bankid::login(); // will redirect user and start a login. After login user is returned to url in config/bankid.php
Bankid::user(); // returns the user previously logged in or false.
protected $routeMiddleware = [
'bankid' => \Patrikgrinsvall\LaravelBankid\BankidMiddleware::class,
Then use in one of the following ways:
// On a single route
Route::get('/profile', function () {
// your stuff
})->middleware('bankid');
// On a group of routes
Route::middleware([BankidMiddleware::class])->group(function () {
Route::get('/your-route', View::render('your-route'))
});
// On a group of routes without adding to kernel
Route::middleware([\Patrikgrinsvall\LaravelBankid\BankidMiddleware::class])->group(function () {
Route::get('/your-route', View::render('your-route'))
});
// Get the user from the session
use Illuminate\Support\Facades\Session;
...
Session::get('bankid.user'); // returns user details as an array
Session::get('bankid.personalNumber'); // returns personal number as a string
Session::get('bankid.name'); // returns full name as a string
Session::get('bankid.givenName'); // returns first name as a string
Session::get('bankid.surname'); // returns lastn name as string
Session::get('bankid.signature'); // returns signature as string.
From facade:
use Patrikgrinsvall\LaravelBankid\BankidFacade;
...
Bankid::user();
composer test
The MIT License (MIT). Please see License File for more information.