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-tool
mode,- 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 -M
to see which algorithms are supported by the ID card. - Run
pkcs11-tool -O
to see which objects (keys) are available on the ID card. - Edit
python authtoken-generator.py
:- Change
PAYLOAD
as needed. - Change
HASH_ALGO
,ALGORITHM
andMECHANISM
to match the algorithm used in signing (step 1); use algorithm names from RFC 7518, section 3, e.g. ES384 forALGORITHM
, copy-pasteMECHANISM
from step 1. - Change
OBJECT_ID
to match the ID of the signing key (step 2). - Change
PIN
to match the signing key PIN. - Make sure
EID
is initialized withPKCS11ElectronicID
.
- Change
- Run
python authtoken-generator.py
.
Optional:
- Change
SLOT_INDEX
to use the signing certificate. - Set the
USER_CERTIFICATE
value 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
EID
is initialized withMobileIDElectronicID
inpython authtoken-generator.py
. - Pass the following arguments to
MobileIDElectronicID
constructor: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
.