This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

PyBankID is a client for performing BankID signing.

The Swedish BankID solution for digital signing uses a SOAP connection solution, and this module aims at providing a simplifying client for making authentication, signing and collect requests to the BankID servers.

For more details about BankID implementation, see the official documentation. There, one can find information about how the BankID methods are defined, how to set up the test environment and obtain the SSL certificate for the test server.

An example web application using PyBankID exists and can be found in deployed state on Heroku.

Installation

PyBankID can be installed though pip:

pip install pybankid

The remedy the InsecurePlatformWarning problem detailed below (Python 2, urllib3 and certificate verification), you can install pybankid with the security extras:

pip install pybankid[security]

This installs the pyopenssl, ndg-httpsclient and pyasn1 packages as well. This does however require the installation of some additional system packages:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

See the cryptography package’s documentation for details.

Usage

First, create a BankIDClient:

>>> from bankid import BankIDClient
>>> client = BankIDClient(certificates=('path/to/certificate.pem',
                                        'path/to/key.pem'))

Connection to production server is the default in the client. If test server is desired, send in the test_server=True keyword in the init of the client.

A sign order is then placed by

>>> client.sign(user_visible_data="The information to sign.",
                personal_number="YYYYMMDDXXXX")
{u'autoStartToken': u'798c1ea1-e67a-4df6-a2f6-164ac223fd52',
 u'orderRef': u'a9b791c3-459f-492b-bf61-23027876140b'}

and an authentication order is initiated by

>>> client.authenticate(personal_number="YYYYMMDDXXXX")
{u'autoStartToken': u'798c1ea1-e67a-4df6-a2f6-164ac223fd52',
 u'orderRef': u'a9b791c3-459f-492b-bf61-23027876140b'}

The status of an order can then be studied by polling with the collect method using the received orderRef:

>>> client.collect(order_ref="a9b791c3-459f-492b-bf61-23027876140b")
{u'progressStatus': u'OUTSTANDING_TRANSACTION'}
>>> client.collect(order_ref="a9b791c3-459f-492b-bf61-23027876140b")
{u'progressStatus': u'USER_SIGN'}
>>> client.collect(order_ref="a9b791c3-459f-492b-bf61-23027876140b")
{u'ocspResponse': u'MIIHfgoBAKCCB3cw[...]',
 u'progressStatus': u'COMPLETE',
 u'signature': u'PD94bWwgdmVyc2lvbj0[...]',
 u'userInfo': {u'givenName': u'Namn',
              u'ipAddress': u'195.84.248.212',
              u'name': u'Namn Namsson',
              u'notAfter': datetime.datetime(2016, 9, 9, 22, 59, 59),
              u'notBefore': datetime.datetime(2014, 9, 9, 23, 0),
              u'personalNumber': u'YYYYMMDDXXXX',
              u'surname': u'Namnsson'}}

The collect should be used sparingly, as not to burden the server unnecessarily.

Python 2, urllib3 and certificate verification

An InsecurePlatformWarning is issued when using the client in Python 2 (See urllib3 documentation). This can be remedied by installing pybankid with the security extras as described above, or to manually install pyopenssl according to this issue and docstrings in requests.

Optionally, the environment variable PYBANKID_DISABLE_WARNINGS can be set to disable these warnings.

Testing

The PyBankID solution can be tested with pytest:

py.test tests/
Release History

Release History

0.3.6

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pybankid-0.3.6-py2.py3-none-any.whl (17.6 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Aug 8, 2016
pybankid-0.3.6.tar.gz (13.7 kB) Copy SHA256 Checksum SHA256 Source Aug 8, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting