2017 © Pedro Peláez
 

library bankid

BankID authentication and filesinging for laravel implementation from dimafi/6/bank-id

image

anwar/bankid

BankID authentication and filesinging for laravel implementation from dimafi/6/bank-id

  • Sunday, May 6, 2018
  • by ringkubd
  • Repository
  • 1 Watchers
  • 1 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

BankID Laravel

BankID implementation php and laravel., (*1)

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system., (*2)

Prerequisites

What things you need to install the software and how to install them, (*3)

1. PHP >= 5.6
2. Soap Extention

Installing

A step by step series of examples that tell you have to get a development env running, (*4)

Say what the step will be, (*5)

Laravel with composer

composer require anwar/bankid

For laravel <= 5.4 Edit config/App.php Add below line on provider, (*6)

        Anwar\Bankid\BankidServiceProvider::class,

And if you want to use Facade, (*7)

        "BankID":Anwar\Bankid\BankidFacad::class,

Implementation

``` PHP <?php namespace App\Http\Controllers; use App\User; use BankID; use Illuminate\Http\Request;, (*8)

class BankidController extends Controller { public function __construct() { $this->middleware('web'); }, (*9)

public function bankid(Request $httpsrequestdata) {
    /**
     * Initial BankID Service With wsdl url and
     * Certificate
     * For test
     */
    //$cer = "E:\\xampp\htdocs\public\ssl/FP.pem";

    //$httpsrequestdata = new Request();

    $initial = BankID::start('https://appapi2.test.bankid.com/rp/v4?wsdl',
        ['local_cert' => $cer],
        false);
    if (session()->has("compl")) {
        # code...
        session()->forget("compl");
        session()->forget("orderRef");
        session()->forget("progress");
    }
    //session()->forget("orderRef");
    //return json_encode(Session()->has("orderRef"));

    if (session()->has("orderRef") && !session()->has('compl') && session()->has("progress")) {
        $response = BankID::collectResponse(session()->get("orderRef"));

        if ($response->progressStatus == "COMPLETE") {

            $user = User::where('personal_number', $httpsrequestdata->personalnumber)->first();

            if ($user != null) {
                //Auth::login($user->id);
                $login = User::bankidauth($user->id);
                if ($login) {
                    session()->forget('personalnm');
                    session()->forget("orderRef");
                    session()->forget("progress");
                    session()->put('compl', 'true');
                    return "loggedin";
                } else {
                    return json_encode($user);
                }

            } else {
                return "loggederror";
            }

            return json_encode($response->userInfo->personalNumber);
        } else {
            //session()->forget("orderRef");
            return $response->progressStatus;
        }
    } else {

        //return $response->progressStatus;
        //return json_encode(Session()->forget('progress'));

        if (!session()->has('orderRef') && !session()->has('progress')) {

            $personalnum = $httpsrequestdata->personalnumber;

            $response1 = BankID::getAuthResponse($personalnum);

            if (is_object($response1) && $response1->orderRef != "") {
                $response = BankID::collectResponse($response1->orderRef);
                session()->put('orderRef', $response1->orderRef);
                session()->put('personalnm', $personalnum);
                session()->put('progress', 'true');
                session('orderRef', $response1->orderRef);
                return json_encode($response1->orderRef);
            } else {
                return $response->progressStatus;
            }

        }
        return json_encode(session()->has('orderRef'));

    }

}

public function isRegister(Request $pnum) {
    return json_encode($pnum);
    $user = User::where('personal_number', $pnum->pnum)->count();
    if ($user != '0') {
        return 'auth';
    } else {
        return 'reg';
    }

}

public function refresh() {
    session()->forget("compl");
    session()->forget("orderRef");
    session()->forget("progress");
    session()->forget('personalnm');
}

}, (*10)


And create a view like ``` PHP <!doctype html> <html lang="{{ app()->getLocale() }}"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Laravel</title> <!-- Fonts --> <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css"> <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous"> </head> <body> <div class="flex-center position-ref full-height"> @if (Route::has('login')) <div class="top-right links"> @auth <a href="{{ url('/home') }}">Home</a> @else <a href="{{ route('login') }}">Login</a> <a href="{{ route('register') }}">Register</a> @endauth </div> @endif <div class="content"> <div class="m-b-md"> <form method="post"> <div class="form-gorup"> <label for="personalnumber">Personal Number</label> <input type="number" id="personalnumber" name="personalnumber" class="form-control" value="199012247590"> <input type="submit" class="btn btn-success" name="psubmit" id="psubmit" value="Submit"> </div> </form> </div> <script src="http://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script> <script> $(document).ready(function() { $(document).on('click', "#psubmit", function(event) { event.preventDefault(); /* Act on the event */ personalnumber = $("#personalnumber").val(); if (personalnumber != "") { //alert(personalnumber); $.ajax({ url: "{{ route('bankid') }}", type: 'GET', data: {personalnumber: personalnumber}, }) .done(function(data,xhs) { console.log(data); }) .fail(function(data) { console.log("error"); }) } }); }); </script> </div> </div> </body> </html>

Original Package

Converting Lravel Package

License

This project is licensed under the MIT License - see the LICENSE.md file for details, (*11)

Acknowledgments

  • For Further Assistant Feel Free to Contact ajr.jahid@gmail.com

The Versions

06/05 2018

dev-master

9999999-dev https://github.com/ringkubd/bankid

BankID authentication and filesinging for laravel implementation from dimafi/6/bank-id

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-soap *

 

by Dmitry Feshchenko
by Oleg Davudyuk
by Anders Fajerson
by Puggan
by MD ANWAR JAHID

23/04 2018

v1.3

1.3.0.0 https://github.com/ringkubd/bankid

BankID authentication and filesinging for laravel implementation from dimafi/6/bank-id

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-soap *

 

by Dmitry Feshchenko
by Oleg Davudyuk
by Anders Fajerson
by Puggan
by MD ANWAR JAHID

23/04 2018

v1.2

1.2.0.0 https://github.com/ringkubd/bankid

BankID authentication and filesinging for laravel implementation from dimafi/6/bank-id

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-soap *

 

by Dmitry Feshchenko
by Oleg Davudyuk
by Anders Fajerson
by Puggan
by MD ANWAR JAHID

23/04 2018

v1.1

1.1.0.0 https://github.com/ringkubd/bankid

BankID authentication and filesinging for laravel implementation from dimafi/6/bank-id

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-soap *

 

by Dmitry Feshchenko
by Oleg Davudyuk
by Anders Fajerson
by Puggan
by MD ANWAR JAHID

23/04 2018

v1.0

1.0.0.0 https://github.com/ringkubd/bankid

BankID authentication and filesinging for laravel implementation from dimafi/6/bank-id

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-soap *

 

by Dmitry Feshchenko
by Oleg Davudyuk
by Anders Fajerson
by Puggan
by MD ANWAR JAHID