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.6.tar.gz (20.9 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.6-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_pcbu-0.1.6.tar.gz
  • Upload date:
  • Size: 20.9 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.6.tar.gz
Algorithm Hash digest
SHA256 7ef6d2f17c6e83efd649462e625b465925e177d5643c0356f2232e2ca0e47fa3
MD5 da49ddd89ee031622fd01628a23884d9
BLAKE2b-256 d12fe779b8042e7963ffe52723709e750fd2320f2b7eaccd8a8277f5dd1fd603

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_pcbu-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f354c1950f3147f68b5f3cbfaedfe85f39a48809a0248931758af69aee76316d
MD5 63bfdd7fa479c320a394b7957380b99b
BLAKE2b-256 e1f68fc28fd77e1cd068e5fdefe1decd0d8cc06a4165cc1b340756516989dff4

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