Skip to content

Commit f82ea38

Browse files
committed
Sigstore: Add an import method with no args
This way the user has to authenticate to the identity they want to sign with later * removes possibility of typos or misunderstanding * Still allows storing the identity and issuer in the URI (this is not implemented here)
1 parent d2cd91a commit f82ea38

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

securesystemslib/signer/_sigstore_signer.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,23 @@ def import_(
211211

212212
return uri, key
213213

214+
@classmethod
215+
def import_via_auth(cls) -> Tuple[str, SigstoreKey]:
216+
"""Create public key and signer URI by interactive authentication
217+
218+
Returns a private key URI (for Signer.from_priv_key_uri()) and a public
219+
key. This method always uses the interactive authentication.
220+
"""
221+
222+
try:
223+
from sigstore.oidc import Issuer
224+
except ImportError as e:
225+
raise UnsupportedLibraryError(IMPORT_ERROR) from e
226+
227+
# authenticate to get the identity and issuer
228+
token = Issuer.production().identity_token()
229+
return cls.import_(token.identity, token.expected_certificate_subject, False)
230+
214231
def sign(self, payload: bytes) -> Signature:
215232
"""Signs payload using the OIDC token on the signer instance.
216233

0 commit comments

Comments
 (0)