forked from almalinux/cas_wrapper
ALBS-662: Added the ability to authenticate other CAS users' artifacts
This commit is contained in:
parent
211d4521c0
commit
4ced19c78c
@ -108,6 +108,7 @@ class CasWrapper:
|
|||||||
local_path: str,
|
local_path: str,
|
||||||
return_json: bool = False,
|
return_json: bool = False,
|
||||||
use_hash: bool = False,
|
use_hash: bool = False,
|
||||||
|
signer_id: str = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Wrapper around `cas authenticate`
|
Wrapper around `cas authenticate`
|
||||||
@ -123,6 +124,8 @@ class CasWrapper:
|
|||||||
command_args = ['authenticate', local_path]
|
command_args = ['authenticate', local_path]
|
||||||
if use_hash:
|
if use_hash:
|
||||||
command_args = ['authenticate', '--hash', local_path]
|
command_args = ['authenticate', '--hash', local_path]
|
||||||
|
if signer_id:
|
||||||
|
command_args.extend(('--signerID', signer_id))
|
||||||
command_args.extend(('-o', 'json'))
|
command_args.extend(('-o', 'json'))
|
||||||
command = self._cas[command_args]
|
command = self._cas[command_args]
|
||||||
try:
|
try:
|
||||||
@ -146,6 +149,7 @@ class CasWrapper:
|
|||||||
def authenticate_source(
|
def authenticate_source(
|
||||||
self,
|
self,
|
||||||
local_path: str,
|
local_path: str,
|
||||||
|
signer_id: str = None,
|
||||||
) -> typing.Tuple[bool, typing.Optional[str]]:
|
) -> typing.Tuple[bool, typing.Optional[str]]:
|
||||||
"""
|
"""
|
||||||
Authenticates source by git path.
|
Authenticates source by git path.
|
||||||
@ -155,7 +159,11 @@ class CasWrapper:
|
|||||||
commit_cas_hash = None
|
commit_cas_hash = None
|
||||||
self.ensure_login()
|
self.ensure_login()
|
||||||
try:
|
try:
|
||||||
result_json = self.authenticate(local_path, return_json=True)
|
result_json = self.authenticate(
|
||||||
|
local_path,
|
||||||
|
return_json=True,
|
||||||
|
signer_id=signer_id
|
||||||
|
)
|
||||||
is_authenticated = result_json['verified']
|
is_authenticated = result_json['verified']
|
||||||
commit_cas_hash = result_json['hash']
|
commit_cas_hash = result_json['hash']
|
||||||
# we can fall with ProcessExecutionError,
|
# we can fall with ProcessExecutionError,
|
||||||
@ -168,6 +176,7 @@ class CasWrapper:
|
|||||||
self,
|
self,
|
||||||
local_path: str,
|
local_path: str,
|
||||||
use_hash: bool = False,
|
use_hash: bool = False,
|
||||||
|
signer_id: str = None,
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
Authenticates artifact by artifact path or hash if `use_hash` is True.
|
Authenticates artifact by artifact path or hash if `use_hash` is True.
|
||||||
@ -180,6 +189,7 @@ class CasWrapper:
|
|||||||
local_path,
|
local_path,
|
||||||
use_hash=use_hash,
|
use_hash=use_hash,
|
||||||
return_json=True,
|
return_json=True,
|
||||||
|
signer_id=signer_id
|
||||||
)['verified']
|
)['verified']
|
||||||
# we can fall with ProcessExecutionError,
|
# we can fall with ProcessExecutionError,
|
||||||
# because artifact can be not notarized
|
# because artifact can be not notarized
|
||||||
|
Loading…
Reference in New Issue
Block a user