Skip to main content

A library to simplify working with the IB1 Trust Framework directory

Project description

IB1 Directory

A library to simplify working with the IB1 Trust Framework directory

Development

Setup

poetry install

Run tests

poetry run pytest

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),
        )
...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ib1_directory-0.1.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

ib1_directory-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file ib1_directory-0.1.1.tar.gz.

File metadata

  • Download URL: ib1_directory-0.1.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/24.0.0

File hashes

Hashes for ib1_directory-0.1.1.tar.gz
Algorithm Hash digest
SHA256 adad1e7f990f28eec1ba8d089be2b9738926696fac4e501c9b56eceff7c33de9
MD5 c8d39df5d4593a2d00b3a1fcd39e000f
BLAKE2b-256 9c39d1d747889ee310d76b9a9388f8bd1d34b0219a93bb619e7c92bd5da6f4a8

See more details on using hashes here.

File details

Details for the file ib1_directory-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ib1_directory-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/24.0.0

File hashes

Hashes for ib1_directory-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ef6e8e108196096fc14baf7b69a3c5ac63c93312d2d4972baecaeca823b0413
MD5 c5660999670d488355b4a88bb43c53cb
BLAKE2b-256 67dbb24c8122e4d0d37d629cf66aa8fc5cb6000c4b692f96d5a93823783216b6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page