DEPRECATED, ONLY VALID FOR LEGACY WEB EID TOKEN v1 FORMAT.
A Python script that generates arbitrary Web eID authentication tokens for
testing using either pkcs11-tool or Estonian Mobile-ID.
- Python 3.8+,
- When using
pkcs11-toolmode,- OpenSC installed,
- electronic ID card connected that is supported by OpenSC.
The script has only been tested on Ubuntu Linux.
The authtoken-generator.py script is only a quick rough helper and needs to
be manually amended for it to work. It can be configured by changing the values
of the global variables in the script.
- Run
pkcs11-tool -Mto see which algorithms are supported by the ID card. - Run
pkcs11-tool -Oto see which objects (keys) are available on the ID card. - Edit
python authtoken-generator.py:- Change
PAYLOADas needed. - Change
HASH_ALGO,ALGORITHMandMECHANISMto match the algorithm used in signing (step 1); use algorithm names from RFC 7518, section 3, e.g. ES384 forALGORITHM, copy-pasteMECHANISMfrom step 1. - Change
OBJECT_IDto match the ID of the signing key (step 2). - Change
PINto match the signing key PIN. - Make sure
EIDis initialized withPKCS11ElectronicID.
- Change
- Run
python authtoken-generator.py.
Optional:
- Change
SLOT_INDEXto use the signing certificate. - Set the
USER_CERTIFICATEvalue to a base64-encoded certificate to use a custom certificate. Otherwise the certificate is read from the card by default.
- Create and activate virtual environment, install the Mobile-ID service client library:
python -m venv venv . venv/bin/activate # . venv/Scripts/activate in Windows pip install git+https://github.com/web-eid/mobile-id-rest-python-client
- Edit
python authtoken-generator.py:- Make sure
EIDis initialized withMobileIDElectronicIDinpython authtoken-generator.py. - Pass the following arguments to
MobileIDElectronicIDconstructor:service_name: Mobile-ID service name, e.g. 'MyCompany',service_uuid: Mobile-ID service UUID, e.g. '09c14dbb-f882-4a53-9a68-335940150f01',user_phone_number: Phone number of the person who authenticates, e.g. '51234567',user_id_code: ID code of the person who authenticates, e.g. '38001085718'.
- Make sure
- Run
python authtoken-generator.py.