Skip to main content

A package to interact with the PC Bio Unlock credentials module.

Project description

py-pcbu

This library simplifies interactions with PC Bio Unlock by implementing its protocol.

Usage

Pairing

  1. First, install PC Bio Unlock normally. Currently, versions >2.0.0 are supported, probably lower versions too.
  2. In the desktop app, click on Pair device. Go through the wizard steps, until you reach the QR Code.
  3. Get the JSON string out of the QR Code. On Android, I can only recommend using the FOSS app https://gitlab.com/Atharok/BarcodeScanner
  4. Write a TCPPairClient as follows:
from pcbu.tcp.pair_client import TCPPairClient
from pcbu.models import PairingQRData

pairing_data = PairingQRData.from_json(your_qr_json_string_here)

client = TCPPairClient(pairing_qr_data=pairing_data, device_name="The name of the device authorizing unlocks")
pair_response = client.pair()
print(pair_response)

This snippet prints in plaintext the payload received from the desktop. It contains sensitive informations such as your account password! So make sure to store it somewhere safe

Unlocking

py-pcbu gives you a base class to create a server listening for TCP unlock requests. Here is a minimalistic code to get it up and running:

from pcbu.models import PCPairing, PCPairingSecret
from pcbu.tcp.unlock_server import TCPUnlockServerBase

pairings_dicts =   [
    {
        "server_ip_address": "192.168.1.Y",
        "pairing_id": "abcdef",
        "desktop_ip_address": "192.168.1.X",
        "encryption_key": "some_super_long_key",
        "username": "user1@desktop",
        "password": "pwd1"
    },
    {
        "server_ip_address": "192.168.2.Z",
        "pairing_id": "ghijk",
        "desktop_ip_address": "192.168.1.X",
        "encryption_key": "another_super_long_key",
        "username": "user2@desktop",
        "password": "pwd2"
    }
]
pc_pairings = [PCPairingSecret.from_dict(d) for d in pairing_dicts]

class TCPUnlockServer(TCPUnlockServerBase):

    def on_valid_unlock_request(self, pairing: PCPairing) -> bool:
        print(f"Accepting unlock request from {pairing.desktop_ip_address}!")
        return True

with TCPUnlockServer(pc_pairings) as server:
    server.listen()

This snippet will start a TCPUnlockServer listening on each of the server_ip_address from the PCPairingSecret list, using port 43298 by default (same as PC Bio Unlock's default). When the server receivces an unlocking request, it will validate that the requestee's ip addres matches one of the PCPairingSecret instances, decrypt the unlock request, and call on_valid_unlock_request which you have to implement. In this snippet, the implementation of on_valid_unlock_request automatically accepts the unlocking request, but you could add more external conditions to allow it.

Development

For easier development, we include two scripts with VSCode launch configuration:

  • scripts/test_pair.py
  • scripts/test_unlock.py

Both scripts expect a gitignored conf.local.json file at the root of the repository. You can cp conf.template.json conf.local.json to get a base file to start from.

Releasing

Releases are automatically created when a change to version in pyproject.toml is detected. The new files are automatically uploaded to PyPI and the signed release is uploaded to GitHub Releases. The current steps to release are:

  1. Make sure pyproject.toml is updated with the new version
  2. Using cucumber/changelog, add the changes and update CHANGELOG.md with the new version
./changelog -o CHANGELOG.md added "Add this and that"
./changelog -o CHANGELOG.md release 0.1.2
  1. Commit the pyproject.toml and CHANGELOG.md changes
  2. Push the changes to GitHub
  3. Wait for the release to be published on PyPI
  4. Wait for the release to be published on GitHub Releases

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

py_pcbu-0.1.7.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_pcbu-0.1.7-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file py_pcbu-0.1.7.tar.gz.

File metadata

  • Download URL: py_pcbu-0.1.7.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for py_pcbu-0.1.7.tar.gz
Algorithm Hash digest
SHA256 fbdcd49ddf9ea194f3902503a4a0d7746c7f8558add28aa34852e5339a825c71
MD5 4ab8d2fd3ab1c20eb81281bd5bf5d35e
BLAKE2b-256 00da569c083c80ca1694b1dc0a90828b579f8cd2bfffd84361156f1847368bed

See more details on using hashes here.

File details

Details for the file py_pcbu-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: py_pcbu-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for py_pcbu-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 2b9e826d27298154d22d38f52acf67576158c0d6d89dfdbbb95e988769660088
MD5 325be06071d39b2a2e8ea308612338b7
BLAKE2b-256 37cfef5aa1411093c12e199ee913b33772829d6ea33b130acc75ededcb71b6e1

See more details on using hashes here.

Supported by

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