Package: wc-bankid-nbu
WebCase NUBUBankIdSDK for NBU's BankID authorization.Simple API client to collect user data.Small wrapper for EUSignCP library for a simpler data manipulation.Python social auth integration: Authorization Backend.Installationpipinstallwc-bankid-nbuCreate folder to store certificates:By default it's:/data/certificates.Here:https://iit.com.ua/downloads. Find and upload to this folder 2 certficate files:CACertificates.p7bCACertificates.Test.p7bThen 2 certificates likeEU-*.cerand private keyKey-6.datalso should be placed there. You will get them from bankid authority.This step is optional, but desirable. Create a folder, like/data/libor something like that for EUSignCP C Library to store there.wc-bankid-nbuhas a default built in binaries, but it would be better to have them in a separate folder.You may copy them fromwc_bankid_nbu/contrib/eu_sign/linux/64or32folder to your special one.Then all your scripts/server/etc. must run with anLD_LIBRARY_PATH=/data/libenvironment variable set to a EUSignCP C Library folder path.UsageThis example will be for django. But there is only a configuration, that can be easily changed for any other project.settings.py# Private key location path and it's password# This must be provided:WC_BANKID_NBU_SIGNER_PRIVATE_KEY_PATH='/data/certificates/Key-6.dat'WC_BANKID_NBU_SIGNER_PRIVATE_KEY_PASS='12345677'# This parameters are optional. The defaults for them are:# Path to a certificates folder.WC_BANKID_NBU_SIGNER_FILE_STORE_PATH='/data/certificates'# EUSignCP module, if you need a custom one.WC_BANKID_NBU_SIGNER_MODULE='wc_bankid_nbu.contrib.eu_sign.EUSignCP'# Name of the sign certificate.WC_BANKID_NBU_SIGNER_CERTIFICATES_SIGN_NAME='EU-5B63D88375D92018040000002E3D0000B1950000.cer'# Name of the distribution certificate.WC_BANKID_NBU_SIGNER_CERTIFICATES_DISTRIBUTION_NAME='EU-5B63D88375D92018040000002E3D0000B2950000.cer'Simple user data queryingfromwc_bankid_nbuimport(PersonalPhysicalDataQuery,APIClient,PersonalInfoDTO,TAddress,TDocument,FPerson,FAddress,FDocument,)# Signer settings that was resolved from django configuration.fromwc_bankid_nbu.contrib.django.confimportsigner_settingsfromwc_bankid_nbuimportAPIClient,Signeruser_data_query=(# Type of data query.PersonalPhysicalDataQuery()# General user fields list that we wish to get..fields(FPerson.FIRST_NAME,FPerson.MIDDLE_NAME,FPerson.LAST_NAME,FPerson.BIRTH_DAY,FPerson.SEX,FPerson.PHONE,FPerson.EMAIL,FPerson.RNOKPP,FPerson.IS_HIGH_RISK,FPerson.IS_PEPS,FPerson.IS_RESTRICTED,FPerson.IS_TERRORIST,FPerson.IS_UA_RESIDENT,)# We only need an actual user's address.# First parameter is Type of address we need, other parameters - required# address fields..address(TAddress.FACTUAL,FAddress.COUNTRY,FAddress.REGION,FAddress.DISTRICT,FAddress.CITY,FAddress.STREET,FAddress.STREET_NUMBER,FAddress.FLAT_NUMBER,)# But two documents: Passport in for of a book and international one.# The same principle is for a `.scans()` data..document(TDocument.PASSPORT_BOOK,FDocument.NAME,FDocument.SERIES,FDocument.NUMBER,FDocument.ISSUED_BY,FDocument.ISSUED_BY_COUNTRY,FDocument.ISSUED_AT,FDocument.EXPIRED_AT,).document(TDocument.PASSPORT_INTERNATIONAL,FDocument.NAME,FDocument.SERIES,FDocument.NUMBER,FDocument.ISSUED_BY,FDocument.ISSUED_BY_COUNTRY,FDocument.ISSUED_AT,FDocument.EXPIRED_AT,))client=APIClient(signer=Signer(signer_settings))data=client.get_personal_data(user_data_query,access_token)print(data['data'])# > User information.print(data['certificate'])# > Information about certificate.Social auth backendauth_backend.pyfromfunctoolsimportcached_propertyfromwc_bankid_nbu.contrib.social_core.backendsimportBankIDNBUBaseBackend# Signer settings that was resolved from django configuration.fromwc_bankid_nbu.contrib.django.confimportsigner_settingsfromwc_bankid_nbuimportAPIClient,Signer,TestAPIClient__all__="BankIDNBU",classBankIDNBU(BankIDNBUBaseBackend):# User data query could be changed like so:# PERSONAL_DATA_QUERY = PersonalPhysicalDataQuery().fields(...)@cached_propertydefclient(self):ClientClass=TestAPIClientifself.setting('DEBUG')elseAPIClientreturnClientClass(signer=Signer(signer_settings))TODO[_] Social auth pipeline integrations.