Python Flash samples project
The Python Flask samples project shows how to use Rest PKI together with Web PKI on a Python project using the Flask framework. It is hosted on GitHub at:
https://github.com/LacunaSoftware/PkiSuiteSamples/tree/master/python/flask
Running the project
- Download the project or clone the repository
- Install dependencies:
pip install -r requirements.txt - Set the
FLASK_APPenvironment variable to define the name of app that should be run:FLASK_APP=sample - Run the web application:
flask run - Access the URL http://localhost:5000
Project map
This section lists where to find the relevant parts in each feature sample on the project.
Authentication with digital certificate
- View: authentication_rest.py
- Templates:
- index.html (JavaScript on signature-form.js)
- success.html
- failed.html
PAdES signature with file already on server
- View: pades_signature_rest.py
- Templates:
- index.html (JavaScript on signature-form.js)
- complete.html
PAdES signature with file uploaded by user
After the file upload (which is crudely implemented merely for demonstration purposes on the view server_files.py and template index.html)
is done the control flow is the same as in the sample PAdES signature with the file already on server, but with the URL parameter userfile filled.
PAdES co-signature
After the control flow of the sample PAdES signature with file already on server is completed an the link Co-sign with another certificate is clicked, the same control flow is repeated, but now with the URL parameter userfile filled.
PAdES marks
Not yet available on this project.
PAdES signature using server key
Not yet available on this project.
Open/validate an existing PAdES signature
- View: open_pades_rest.py
- Template: index.html
Printer-friendly version
After the control flow of the sample PAdES signature with file already on server is completed and the link Download a printer-friendly version of the signed file is clicked, the flow goes to the view printer_version_pades_rest.py with the signed file's id in the URL.
CAdES signature with file already on server
- View: cades_signature_rest.py
- Templates:
- index.html (JavaScript on signature-form.js)
- complete.html
CAdES signature with file uploaded by user
After the file upload (which is crudely implemented merely for demonstration purposes on the view server_files.py and template index.html) is done the control flow is the same as in the sample CAdES signature with file already on server, but with the URL parameter userfile filled.
CAdES co-signature
After the control flow of the sample CAdES signature with file already on server is completed and the link Co-sign with another certificate is clicked, the same control flow is repeated, but now with the URL parameter cmsfile filled.
Open/validate an existing CAdES signature
Not yet available on this project.
XML signature of the entire document
- View: xml_signature_rest.py
- Templates:
- index.html (JavaScript on signature-form.js)
- complete.html
XML signature of an element
- View: xml_nfe_signature_rest.py
- Templates:
- index.html (JavaScript on signature-form.js)
- complete.html
XAdES signature of an element
Demonstrated by the digital diploma sample, which signs the DadosDiploma and DadosRegistro elements with the ICP-Brasil XAdES AD-RT policy and then the whole document with the AD-RA policy:
- View: xml_diploma_signature_rest.py
- Templates:
Open/validate signatures on an existing XML file
Not yet available on this project.
Batch of PAdES signatures
- View: batch_pades_rest.py
- Template: index.html (JavaScript on batch-signature-restpki-form.js)
Batch of CAdES signatures
- View: batch_cades_rest.py
- Template: index.html (JavaScript on batch-signature-restpki-form.js)