Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package data version for key use #22

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include signatures *
5 changes: 4 additions & 1 deletion badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
from cryptography.exceptions import InvalidSignature
import json
import pkg_resources as pkgrs

@click.command()
@click.option('-b','--badge-name',help="name of the badge formated like type.YYYY-MM-DD")
Expand All @@ -21,7 +22,9 @@ def verify_badge(badge_name,approver,signature):
# read public key for the approver
# TODO: fix this to read from installed package data
# TODO: make install save the file
with open(approver,'rb') as f:
approver_rel = os.path.join('signatures', approver)
approver_key_file = pkgrs.resource_filename(__name__,approver_rel)
with open(approver_key_file, 'rb') as f:
public_bytes = f.read() # read file

signer_key = Ed25519PublicKey.from_public_bytes(public_bytes)
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
'verifyjson = badges:process_badges'
],
},

zip_safe=False,
include_package_data=True,
)