octomachinery.github.models.private_key module

Private key container.

class octomachinery.github.models.private_key.GitHubPrivateKey(b_raw_data: bytes)[source]

Bases: object

Private key entity with a pre-calculated SHA-1 fingerprint.

Parameters

b_raw_data (bytes) – the contents of a PEM file

property fingerprint

Colon-separated SHA-1 fingerprint string value.

Returns

colon-separated SHA-1 fingerprint

Return type

str

classmethod from_file(path)[source]

Construct a GitHubPrivateKey instance.

Returns

the GitHubPrivateKey instance constructed of the target file contents

Return type

GitHubPrivateKey

make_jwt_for(*, app_id: int, time_offset: int = 60) → str[source]

Generate app’s JSON Web Token.

Parameters
  • app_id (int) – numeric ID of a GitHub App

  • time_offset (int) – duration of the JWT’s validity, in seconds, defaults to 60

Returns

JWT string for a GitHub App valid for the given time

Return type

str

Raises

ValueError – if time_offset exceeds 600 seconds (10 minutes)

matches_fingerprint(other_hash)[source]

Compare our SHA-1 fingerprint with other_hash.

Returns

the result of own fingerprint comparison with other_hash

Return type

bool

octomachinery.github.models.private_key.extract_private_key_sha1_fingerprint(rsa_private_key)[source]

Retrieve the private key SHA-1 fingerprint.

Parameters

rsa_private_key (cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey) – private key object

Returns

colon-separated SHA-1 fingerprint

Return type

str