imbi-plugin-github 2.45.0__py3-none-any.whl → 2.46.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -189,13 +189,15 @@ class _Locator(pydantic.BaseModel):
189
189
  title='Private key',
190
190
  )
191
191
  #: ``owner/name`` repositories for ``marketplace_fetch``: the
192
- #: marketplaces and their external plugins. Other purposes use the
192
+ #: marketplaces and their external plugins; empty allows each
193
+ #: repository of the installation. Other purposes use the
193
194
  #: repositories of the task's project.
194
195
  repositories: list[str] = pydantic.Field(
195
196
  default_factory=list[str],
196
197
  description=(
197
- 'owner/name, for marketplace_fetch only. Other purposes use'
198
- " the repositories of the task's project."
198
+ 'owner/name, for marketplace_fetch only. Empty: each'
199
+ ' repository of the installation. Other purposes use the'
200
+ " repositories of the task's project."
199
201
  ),
200
202
  title='Repositories',
201
203
  )
@@ -477,7 +479,12 @@ class GitHubApp(secrets.SecretProvider):
477
479
  async def health(
478
480
  self, config: dict[str, typing.Any], organization_id: str
479
481
  ) -> secrets.Health:
480
- """Check that the GitHub API answers. No credentials are used."""
482
+ """Check that the GitHub API answers. No credentials are used.
483
+
484
+ A GHEC tenant refuses each anonymous call (401 or 404), so each
485
+ answer other than a redirect, a rate limit or 5xx shows that the
486
+ API answers. A redirect is usually a proxy login page.
487
+ """
481
488
  try:
482
489
  async with httpx.AsyncClient(
483
490
  base_url=_api_base(_host(config)),
@@ -489,7 +496,16 @@ class GitHubApp(secrets.SecretProvider):
489
496
  return secrets.Health('unhealthy', err.reason)
490
497
  except httpx.TransportError:
491
498
  return secrets.Health('unhealthy', 'unreachable')
492
- if response.status_code != 200:
499
+ status = response.status_code
500
+ rate_limited = status == 429 or (
501
+ status == 403
502
+ and (
503
+ response.headers.get('x-ratelimit-remaining') == '0'
504
+ or 'retry-after' in response.headers
505
+ or 'secondary rate limit' in response.text.lower()
506
+ )
507
+ )
508
+ if 300 <= status < 400 or rate_limited or status >= 500:
493
509
  return secrets.Health('unhealthy', 'provider_error')
494
510
  return secrets.Health('healthy', identity={'host': _host(config)})
495
511
 
@@ -607,9 +623,14 @@ class GitHubApp(secrets.SecretProvider):
607
623
  """Mint a token for the task's repositories and the purpose.
608
624
 
609
625
  ``marketplace_fetch`` uses the repository that the runner asks
610
- for, which must be in the ``repositories`` of the binding; with
611
- none, all of them. The other purposes use the verified repository
612
- ids of the task's project (:meth:`project_repository_ids`).
626
+ for. When the binding lists ``repositories``, the repository must
627
+ be one of them; an empty list allows each repository of the
628
+ installation; the token then covers only that one repository. A
629
+ request without a repository gets every listed repository, and
630
+ none with an empty list (the runner always names one).
631
+ The other purposes use the verified repository ids of all the
632
+ task's projects (:meth:`project_repository_ids`). A project with
633
+ no verified repository adds none.
613
634
 
614
635
  Raises:
615
636
  BrokerError: The purpose is unknown, the task has no
@@ -629,7 +650,7 @@ class GitHubApp(secrets.SecretProvider):
629
650
  if context.purpose == 'marketplace_fetch':
630
651
  repositories = list(locator.get('repositories', []))
631
652
  if context.repository is not None:
632
- if context.repository.lower() not in {
653
+ if repositories and context.repository.lower() not in {
633
654
  name.lower() for name in repositories
634
655
  }:
635
656
  raise secrets.BrokerError(
@@ -637,9 +658,19 @@ class GitHubApp(secrets.SecretProvider):
637
658
  )
638
659
  repositories = [context.repository]
639
660
  else:
640
- repository_ids = await self.project_repository_ids(
641
- _host(config), context.project_id
642
- )
661
+ found: set[int] = set()
662
+ for project_id in context.project_ids:
663
+ with contextlib.suppress(secrets.BrokerError):
664
+ found.update(
665
+ await self.project_repository_ids(
666
+ _host(config), project_id
667
+ )
668
+ )
669
+ if context.project_ids and not found:
670
+ raise secrets.BrokerError(
671
+ 'secret_access_denied', 'project_repository_unverified'
672
+ )
673
+ repository_ids = sorted(found)
643
674
  # An empty list never reaches GitHub: no repositories would give
644
675
  # a token for every repository of the installation.
645
676
  if not repositories and not repository_ids:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: imbi-plugin-github
3
- Version: 2.45.0
3
+ Version: 2.46.0
4
4
  Summary: GitHub identity plugin for Imbi (github.com / GHEC / GHES)
5
5
  Author-email: "Gavin M. Roy" <gavinr@aweber.com>
6
6
  License-Expression: BSD-3-Clause
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.14
13
13
  Requires-Python: >=3.14
14
14
  Requires-Dist: httpx>=0.27
15
- Requires-Dist: imbi-common[databases]==2.45.0
15
+ Requires-Dist: imbi-common[databases]==2.46.0
16
16
  Requires-Dist: pydantic>=2
17
17
  Requires-Dist: pyjwt[crypto]>=2.8
18
18
  Description-Content-Type: text/markdown
@@ -12,7 +12,7 @@ imbi/plugins/github/plugin.py,sha256=LDFCqj6e2jfF9io3U7cC0eVOUAxw1ENvFS-0AWOMuDc
12
12
  imbi/plugins/github/public.py,sha256=GZnTLbj_Gl5sHWuRqFuajnoO2xPudNQumAt4h_uJpYw,3114
13
13
  imbi/plugins/github/pull_requests.py,sha256=DH9CnJoCpY5Ats5sZ_ktLvy54kBwK9g_-CDMlAIOq7Y,32553
14
14
  imbi/plugins/github/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- imbi/plugins/github/secret_provider.py,sha256=hQrPxjdWkZaJxiF3JcTRwjOqHuBrTJaUxT4UIlgPjF8,27968
16
- imbi_plugin_github-2.45.0.dist-info/METADATA,sha256=gf_B7Tmrvz7leBpI2IFz6x0a4lOG2-D_mmMnF9vlGU0,8977
17
- imbi_plugin_github-2.45.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
- imbi_plugin_github-2.45.0.dist-info/RECORD,,
15
+ imbi/plugins/github/secret_provider.py,sha256=6o8-RK22CqoJxeLYFP_sm976anIR_2XR0FAGCfNrnkg,29447
16
+ imbi_plugin_github-2.46.0.dist-info/METADATA,sha256=UbqnZPzDbOwNWSP-P_Yhbu-OM5rbMzxO_6Nzb_eYFrQ,8977
17
+ imbi_plugin_github-2.46.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
+ imbi_plugin_github-2.46.0.dist-info/RECORD,,