bankid-php

BankID SDK

MIT License

Downloads
11
Stars
4

BankID SDK library

A SDK for providing BankID services as a RP (Relying party). Supports the latest v5 features.

Installation

The library can be installed through composer

composer require nicklasw/bankid-sdk

Features

  • Supports all v5 features
  • Supports asynchronous and parallel requests

Examples

Initiate authenticate request

$client = new Client(new Config(<CERTFICATE>));

$authenticationResponse = $client->authenticate(new AuthenticationPayload(<PERSONAL NUMBER>, <IP ADDRESS>));

if (!$authenticationResponse->isSuccess()) {
    var_dump($authenticationResponse->getErrorCode(), $authenticationResponse->getDetails());

    return;
}

$collectResponse = $authenticationResponse->collect(); 

Execute parallel requests

$client = new ClientAsynchronous(new Config(<CERTFICATE>));

$promises[] = $client->authenticate(new AuthenticationPayload(<PERSONAL NUMBER>, <IP ADDRESS>));
$promises[] = $client->authenticate(new AuthenticationPayload(<PERSONAL NUMBER>, <IP ADDRESS>));

// Parallel requests, authenticate users
foreach (unwrap($promises) as $result) {
    /**
     * @var AuthenticationResponse $result
     */
    var_dump($result->isSuccess());
}

Certificates

The web service API can only be accessed by a RP that has a valid SSL client certificate. The RP certificate is obtained from the bank that the RP has purchased the BankID service from.

Generate PEM certificate

openssl pkcs12 -in <filename>.pfx -out <cert>.pem -nodes

Docker

make && make bash

Unit tests

composer run test

Contributing

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Useful information about your new features'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

Contributors