Skip to content

Commit c0c607c

Browse files
authored
Merge pull request #842 from L77H/sigstore-signer-import-github-actions
SigstoreSigner: convenience function for GitHub import
2 parents 2cebfdd + e7a2c1d commit c0c607c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

securesystemslib/signer/_sigstore_signer.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,28 @@ def sign(self, payload: bytes) -> Signature:
268268
bundle_json["messageSignature"]["signature"],
269269
{"bundle": bundle_json},
270270
)
271+
272+
@classmethod
273+
def import_github_actions(
274+
cls, project: str, workflow_path: str, ref: Optional[str] = "refs/heads/main"
275+
) -> Tuple[str, SigstoreKey]:
276+
"""Convenience method to build identity and issuer string for import_() from
277+
GitHub project and workflow path.
278+
279+
Args:
280+
project: GitHub project name (example:
281+
"secure-systems-lab/securesystemslib")
282+
workflow_path: GitHub workflow path (example:
283+
".github/workflows/online-sign.yml")
284+
ref: optional GitHub ref, defaults to refs/heads/main
285+
286+
Returns:
287+
uri: string
288+
key: SigstoreKey
289+
290+
"""
291+
identity = f"https://github.com/{project}/{workflow_path}@{ref}"
292+
issuer = "https://token.actions.githubusercontent.com"
293+
uri, key = cls.import_(identity, issuer)
294+
295+
return uri, key

0 commit comments

Comments
 (0)