IB1 Directory
A library to simplify working with the IB1 Trust Framework directory
Development
Setup
poetry install
Run tests
poetry run pytest
Package and publish
poetry build
poetry publish
Usage
Encoding and decoding
from ib1.directory.extensions import encode_roles, decode_roles
...
cert_builder = (
x509.CertificateBuilder()
.subject_name(subject)
.issuer_name(issuer)
.public_key(private_key.public_key())
.serial_number(x509.random_serial_number())
.not_valid_before(datetime.utcnow())
.not_valid_after(datetime.utcnow() + timedelta(days=365))
)
cert_builder = encode_roles(cert_builder, roles)
cert = cert_builder.sign(private_key, hashes.SHA256(), default_backend())
roles = decode_roles(cert)
Require a role
from ib1 import directory
...
cert = directory.parse_cert(quoted_certificate_from_header)
try:
directory.require_role(
"https://registry.core.ib1.org/scheme/perseus/role/carbon-accounting",
cert,
)
except directory.CertificateRoleError as e:
raise HTTPException(
status_code=401,
detail=str(e),
)
...
Commands for generating certificates
The included cli can generate CA and issuer key certificate pairs suitable for signing client and server CSR requests in the IB1 Trust Framework.
Generate a CA key and certificate
Usage: ib1-directory create-ca [OPTIONS]
Generate a server signing CA key and certificate and an issuer key and
certificate pair signed by the CA then saves all files to disk
Options:
-u, --usage [signing|client|server] Choose signing, server or client CA
-c, --country TEXT Country to use for certificate generation
-s, --state TEXT State to use for certificate generation
-f, --framework TEXT Framework this certificate is for
--help Show this message and exit.
eg. to create a server CA key and certificate for the Core Trust Framework:
poetry run ib1-directory create-ca -u server -f Core
Create test client and server certficates
Client:
Usage: ib1-directory create-client-certificates [OPTIONS]
Create a private key and use it generate a CSR, then sign the CSR with a CA
key and certificate.
Saves the private key, CSR, certificate and bundle to disk.
Options:
--issuer-key-file FILENAME Issuer key file
--issuer-cert-file FILENAME Issuer certificate file
--member-uri TEXT Member uri
--application-uri TEXT Application uri
--organization-name TEXT Organization name
--country TEXT Country
--state TEXT State
-r, --role TEXT Client roles
--help Show this message and exit.
Server:
Usage: ib1-directory create-server-certificates [OPTIONS]
Create a private key and use it generate a CSR, then sign the CSR with a CA
key and certificate.
Saves the private key, CSR, certificate and bundle to disk.
Options:
--issuer-key-file FILENAME Issuer key file
--issuer-cert-file FILENAME Issuer certificate file
--domain TEXT Domain name
--trust-framework TEXT Trust framework
--country TEXT Country
--state TEXT State
--help Show this message and exit.
Metadata
Release files for ib1-directory 0.9.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ib1_directory-0.9.2.tar.gz | 9.0 kB | Without provenance | Details for ib1_directory-0.9.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ib1_directory-0.9.2-py3-none-any.whl | Python 3 | none | any | Details for ib1_directory-0.9.2-py3-none-any.whl |
Total release size: 19.9 kB
Release files / ib1_directory-0.9.2.tar.gz
| Download URL | ib1_directory-0.9.2.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fcd43572b3a969dca64e6830783cec802e280b6716f324dfc5e407e0999823dd
|
|
BLAKE2b-256 checksum How to use checksums |
468c34a05b0636cdaa94808cfe50f62787cc564ef154bb789c5be3ff64630359
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.3 Darwin/24.0.0
|
Release files / ib1_directory-0.9.2-py3-none-any.whl
| Download URL | ib1_directory-0.9.2-py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e089fcd968c0076775fdc1d8542d5cde47ab376041717a8af260c97819a9141f
|
|
BLAKE2b-256 checksum How to use checksums |
490f6f763cdd5fdc382ea0552fdb9efe9ea0b12d683119e9b1666fe6e1d5ce2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.3 Darwin/24.0.0
|
Security for ib1-directory 0.9.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.