Skip to content

Commit 86c74e4

Browse files
author
l77h
committed
import_github_actions function added to SigstoreSigner
1 parent 20be13f commit 86c74e4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

securesystemslib/signer/_sigstore_signer.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,26 @@ 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
281+
worfklow_path: GitHub workflow path
282+
ref: optional GitHub ref, defaults to refs/heads/main
283+
284+
Returns:
285+
uri: string
286+
key: SigstoreKey
287+
288+
"""
289+
identity = f"https://github.com/{project}/{workflow_path}@{ref}"
290+
issuer = "https://token.actions.githubusercontent.com"
291+
uri, key = cls.import_(identity, issuer)
292+
293+
return uri, key

0 commit comments

Comments
 (0)