Updated authentication process for gam print|show projects.
Some checks failed
Build and test GAM / build (Win64, build, 8, VC-WIN64A, windows-2022) (push) Has been cancelled
Build and test GAM / build (aarch64, build, 3, linux-aarch64, [self-hosted linux arm64]) (push) Has been cancelled
Build and test GAM / build (aarch64, build, 5, linux-aarch64, [self-hosted linux arm64], yes) (push) Has been cancelled
Build and test GAM / build (aarch64, build, 7, darwin64-arm64, macos-14) (push) Has been cancelled
Build and test GAM / build (x86_64, build, 1, linux-x86_64, ubuntu-22.04) (push) Has been cancelled
Build and test GAM / build (x86_64, build, 2, linux-x86_64, ubuntu-24.04) (push) Has been cancelled
Build and test GAM / build (x86_64, build, 4, linux-x86_64, ubuntu-22.04, yes) (push) Has been cancelled
Build and test GAM / build (x86_64, build, 6, darwin64-x86_64, macos-13) (push) Has been cancelled
Build and test GAM / build (x86_64, test, 10, ubuntu-24.04, 3.10) (push) Has been cancelled
Build and test GAM / build (x86_64, test, 11, ubuntu-24.04, 3.11) (push) Has been cancelled
Build and test GAM / build (x86_64, test, 12, ubuntu-24.04, 3.12) (push) Has been cancelled
Build and test GAM / build (x86_64, test, 9, ubuntu-24.04, 3.9) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Check for Google Root CA Updates / check-apis (push) Has been cancelled
Build and test GAM / merge (push) Has been cancelled
Build and test GAM / publish (push) Has been cancelled

This commit is contained in:
Ross Scroggs
2024-10-21 10:17:34 -07:00
parent ef14359d9b
commit d7e36bc5eb
5 changed files with 26 additions and 28 deletions

View File

@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
"""
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__version__ = '7.00.24'
__version__ = '7.00.25'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
#pylint: disable=wrong-import-position
@@ -11381,19 +11381,21 @@ def _getProjects(crm, pfilter, returnNF=False):
query=pfilter)
if projects:
return projects
if not pfilter:
if (not pfilter) or pfilter == GAM_PROJECT_FILTER:
return []
if pfilter.startswith('id:'):
projects = [callGAPI(crm.projects(), 'get',
throwReasons=[GAPI.BAD_REQUEST, GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED],
name=f'projects/{pfilter[3:]}')]
if projects or not returnNF:
return projects
return [{'projectId': pfilter[3:], 'state': 'NF'}]
if projects or not returnNF:
return projects
return []
except (GAPI.badRequest, GAPI.invalidArgument) as e:
entityActionFailedExit([Ent.PROJECT, pfilter], str(e))
except GAPI.permissionDenied:
return []
if (not pfilter) or (not pfilter.startswith('id:')) or (not returnNF):
return []
return [{'projectId': pfilter[3:], 'state': 'NF'}]
def _checkProjectFound(project, i, count):
if project.get('state', '') != 'NF':
@@ -11561,6 +11563,8 @@ def _getLoginHintProjects(createSvcAcctCmd=False, deleteSvcAcctCmd=False, printS
if login_hint and login_hint.find('@') == -1:
Cmd.Backup()
login_hint = None
if readOnly and login_hint and login_hint != _getAdminEmail():
readOnly = False
projectIds = None
pfilter = getString(Cmd.OB_STRING, optional=True)
if not pfilter:
@@ -11602,15 +11606,9 @@ def _getLoginHintProjects(createSvcAcctCmd=False, deleteSvcAcctCmd=False, printS
login_hint = _getValidateLoginHint(login_hint, projectId)
crm = None
if readOnly:
_getSvcAcctData()
if (GM.Globals[GM.SVCACCT_SCOPES_DEFINED] and
(API.CLOUDRESOURCEMANAGER in GM.Globals[GM.SVCACCT_SCOPES] or
API.CLOUDRESOURCEMANAGER_V1 in GM.Globals[GM.SVCACCT_SCOPES])): #Backwards compatibility hack
# Removed 6.21.05
# _, crm = buildGAPIServiceObject(API.CLOUDRESOURCEMANAGER, login_hint)
_, crm = buildGAPIServiceObject(API.CLOUDRESOURCEMANAGER, None)
if crm:
httpObj = crm._http
_, crm = buildGAPIServiceObject(API.CLOUDRESOURCEMANAGER, None)
if crm:
httpObj = crm._http
if not crm:
httpObj, crm = getCRMService(login_hint)
if projectIds is None:
@@ -11620,7 +11618,7 @@ def _getLoginHintProjects(createSvcAcctCmd=False, deleteSvcAcctCmd=False, printS
else:
projects = _getProjects(crm, f'id:{projectId}', returnNF=True)
else:
projects = _getProjects(crm, pfilter)
projects = _getProjects(crm, pfilter, returnNF=printShowCmd)
else:
projects = []
for projectId in projectIds: