imbi-plugin-github 2.53.0__py3-none-any.whl → 2.55.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.
@@ -76,6 +76,18 @@ PURPOSE_PERMISSIONS: dict[str, dict[str, str]] = {
76
76
  },
77
77
  }
78
78
 
79
+ #: CI read permissions that a purpose adds when the installation grants
80
+ #: them, so an agent can wait for and read checks. Asking for one the
81
+ #: installation lacks would make GitHub refuse the whole token (422).
82
+ PURPOSE_OPTIONAL_PERMISSIONS: dict[str, dict[str, str]] = {
83
+ 'github_read': {'checks': 'read', 'statuses': 'read'},
84
+ 'github_write': {
85
+ 'actions': 'read',
86
+ 'checks': 'read',
87
+ 'statuses': 'read',
88
+ },
89
+ }
90
+
79
91
  #: The binding test asks for the smallest permission set.
80
92
  _TEST_PERMISSIONS = {'metadata': 'read'}
81
93
 
@@ -284,6 +296,25 @@ def _options(raw: object) -> dict[str, typing.Any]:
284
296
  return {}
285
297
 
286
298
 
299
+ def _with_granted(
300
+ permissions: dict[str, str],
301
+ optional: dict[str, str],
302
+ installation: dict[str, typing.Any] | None,
303
+ ) -> dict[str, str]:
304
+ """``permissions`` plus each optional one the installation grants."""
305
+ if not optional or installation is None:
306
+ return permissions
307
+ granted = typing.cast(
308
+ dict[str, str], installation.get('permissions') or {}
309
+ )
310
+ extra = {
311
+ name: level
312
+ for name, level in optional.items()
313
+ if name not in permissions and granted.get(name) in (level, 'write')
314
+ }
315
+ return permissions | extra
316
+
317
+
287
318
  def _expiry(value: object) -> datetime.datetime:
288
319
  if isinstance(value, str):
289
320
  try:
@@ -651,6 +682,7 @@ class GitHubApp(secrets.SecretProvider):
651
682
  raise secrets.BrokerError(
652
683
  'secret_access_denied', 'purpose_not_supported'
653
684
  )
685
+ optional = PURPOSE_OPTIONAL_PERMISSIONS.get(context.purpose, {})
654
686
  repositories: list[str] = []
655
687
  repository_ids: list[int] | None = None
656
688
  if context.purpose == 'marketplace_fetch':
@@ -698,7 +730,7 @@ class GitHubApp(secrets.SecretProvider):
698
730
  client, repositories, repository_ids
699
731
  )
700
732
  installation_id = str(installation['id'])
701
- elif repositories:
733
+ elif repositories or optional:
702
734
  installation = await self._installation(
703
735
  client, installation_id
704
736
  )
@@ -708,7 +740,7 @@ class GitHubApp(secrets.SecretProvider):
708
740
  token, expires_at = await self._mint(
709
741
  client,
710
742
  installation_id,
711
- permissions,
743
+ _with_granted(permissions, optional, installation),
712
744
  names,
713
745
  repository_ids,
714
746
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: imbi-plugin-github
3
- Version: 2.53.0
3
+ Version: 2.55.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.53.0
15
+ Requires-Dist: imbi-common[databases]==2.55.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=qQtLH3bsueL3UgQQiJxHPsWvSZkEhg_KOx-PlAG6goE,29589
16
- imbi_plugin_github-2.53.0.dist-info/METADATA,sha256=RTNJDm4Al_19WQsGIpdvzvit5gHZexYJ0B5vxH_NA3I,8977
17
- imbi_plugin_github-2.53.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
- imbi_plugin_github-2.53.0.dist-info/RECORD,,
15
+ imbi/plugins/github/secret_provider.py,sha256=E8TKo1O6YSnZO6YUWwK4x3dO-5cg1_M8o2Jd-0YCa_8,30743
16
+ imbi_plugin_github-2.55.0.dist-info/METADATA,sha256=u-aS1Ucc726wpcsfebfb-Cb7EkTLW49jiePhZw1HgHE,8977
17
+ imbi_plugin_github-2.55.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
18
+ imbi_plugin_github-2.55.0.dist-info/RECORD,,