graphcore-kernel 0.2.2__py3-none-any.whl → 0.2.3__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.
@@ -37,6 +37,7 @@ GRAPHCORE_TRUSTED_ISSUERS = [{
37
37
  'web_client_id': 'notes-web', # optional: the public client the web frontend signs in as
38
38
  }]
39
39
  GRAPHCORE_PUBLIC_URL = 'https://notes.example.com' # optional: this deployment's origin behind a proxy
40
+ GRAPHCORE_RESOURCE_SCOPES = [] # optional: scopes the resource metadata offers MCP hosts
40
41
  ```
41
42
 
42
43
  - `issuer` and `audience` are required. An entry without both raises
@@ -127,7 +128,7 @@ points at it:
127
128
  ```
128
129
  GET /.well-known/oauth-protected-resource[/mcp]
129
130
  {"resource": "<origin>[/mcp]", "authorization_servers": ["<issuer>", …],
130
- "bearer_methods_supported": ["header"], "scopes_supported": ["openid"]}
131
+ "bearer_methods_supported": ["header"]}
131
132
 
132
133
  401 WWW-Authenticate: Bearer resource_metadata="<origin>/.well-known/oauth-protected-resource"
133
134
  ```
@@ -136,6 +137,12 @@ GET /.well-known/oauth-protected-resource[/mcp]
136
137
  host, which must pass `ALLOWED_HOSTS` (localhost under `DEBUG`) so a forged
137
138
  `Host` is never echoed.
138
139
 
140
+ `scopes_supported` appears only when `GRAPHCORE_RESOURCE_SCOPES` lists scopes.
141
+ An MCP host that registers a client asks for exactly these, and some issuers
142
+ then give the client only those: Keycloak refuses `openid`, which is not one
143
+ of its client scopes, and a client registered with no scope gets the realm's
144
+ default scopes, the audience among them.
145
+
139
146
  Clients start from this document, never from a configured issuer URL:
140
147
 
141
148
  | Client | Flow at the issuer |
@@ -31,12 +31,15 @@ def metadata_url(base: str, resource_path: str = '') -> str:
31
31
 
32
32
 
33
33
  def document(base: str, resource_path: str = '') -> dict:
34
- return {
34
+ metadata = {
35
35
  'resource': base + resource_path,
36
36
  'authorization_servers': list(trusted_issuers()),
37
37
  'bearer_methods_supported': ['header'],
38
- 'scopes_supported': ['openid'],
39
38
  }
39
+ # Clients that register dynamically copy these into their request; unset, the issuer picks.
40
+ if scopes := list(getattr(settings, 'GRAPHCORE_RESOURCE_SCOPES', ())):
41
+ metadata['scopes_supported'] = scopes
42
+ return metadata
40
43
 
41
44
 
42
45
  def challenge(base: str, resource_path: str = '') -> str:
@@ -32,7 +32,6 @@ class ProtectedResourceMetadataTests(TestCase):
32
32
  'resource': 'http://localhost:8000/mcp',
33
33
  'authorization_servers': ['https://one.example', 'https://two.example'],
34
34
  'bearer_methods_supported': ['header'],
35
- 'scopes_supported': ['openid'],
36
35
  })
37
36
  self.assertEqual(response.headers['access-control-allow-origin'], '*')
38
37
 
@@ -40,6 +39,11 @@ class ProtectedResourceMetadataTests(TestCase):
40
39
  response = await self.get('/.well-known/oauth-protected-resource')
41
40
  self.assertEqual(response.json()['resource'], 'http://localhost:8000')
42
41
 
42
+ @override_settings(GRAPHCORE_RESOURCE_SCOPES=['openid', 'notes'])
43
+ async def test_configured_scopes_are_offered(self):
44
+ response = await self.get('/.well-known/oauth-protected-resource/mcp')
45
+ self.assertEqual(response.json()['scopes_supported'], ['openid', 'notes'])
46
+
43
47
  @override_settings(GRAPHCORE_PUBLIC_URL='https://app.example')
44
48
  async def test_public_url_overrides_the_host(self):
45
49
  response = await self.get('/.well-known/oauth-protected-resource/mcp')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: graphcore-kernel
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: GraphCore platform kernel (entities, strategies, transport, auth)
5
5
  Author: GraphCore
6
6
  License-Expression: Apache-2.0
@@ -38,12 +38,12 @@ graphcore/api/tests/test_predicate_codec.py,sha256=0EFakHVkBfcynrTuRzEjQ722H0IHq
38
38
  graphcore/api/tests/test_strategy_tokens.py,sha256=ZkZDjUkUS0X6QETkxobCR_29EG7JrvChSBdjRDmQRwI,7180
39
39
  graphcore/api/tests/test_subtree_query.py,sha256=f2fH4tXuuRDJpTXSkFLA62k5LWJR0LcdL82gBNDHlNA,3172
40
40
  graphcore/auth/__init__.py,sha256=FC0n8yHDNVUw-PmOgq-e_YIhpDpobF1LOyW1NFDIfT0,56
41
- graphcore/auth/authn/README.md,sha256=xBWgvREH95jKXYuFpW6MVuRrozcdEDvM1wk9Vk4HP-Y,12342
41
+ graphcore/auth/authn/README.md,sha256=UNhVN4-Ee8kRiSfz1kS9bLiwYAqrlKcy1i6ghqtbk_c,12778
42
42
  graphcore/auth/authn/__init__.py,sha256=nKF01Qjq-qpO8GW1hMAEnv6-5QobRPY0M1FxT7-RE-Q,88
43
43
  graphcore/auth/authn/authenticator.py,sha256=rFcZElA4qiVKue8jLd4gT5aF9WYm5jlAmyKq1DC9fGg,4352
44
44
  graphcore/auth/authn/onboarding.py,sha256=lXMnDHm6nv1jHESmEr03PoCQO3DdaYHRnlmVXPgQVIQ,4811
45
45
  graphcore/auth/authn/principals.py,sha256=lnNVuDonTladCMlD_0JcYQnV-ecaqdXKiRBBRfzkLUU,966
46
- graphcore/auth/authn/resource_metadata.py,sha256=ANa6sRssyeW0aJ0cv9Sf2aurOo65ZqzzvJR9GU9GLvE,1696
46
+ graphcore/auth/authn/resource_metadata.py,sha256=C1D82WJKWTq6VbxtL_9uz5xg88L7Y7g9MSTlOjKdenY,1897
47
47
  graphcore/auth/authn/service_accounts.py,sha256=CzsAKQ9C4on6CCZCfE7a2X_1e0qIUW_ILfZ8zSFwRmU,4077
48
48
  graphcore/auth/authn/strategy_tokens.py,sha256=kZXWFgslkIrpTXj4NEMbuJ97YBYzntZjVlSQIb-ba10,1562
49
49
  graphcore/auth/authn/testing.py,sha256=R-1-rBmZ3YpC7SJmwTSoQh7Nk_8Ieehn1VKeBM7-Fto,3439
@@ -322,7 +322,7 @@ graphcore/transport/tests/test_agent_client.py,sha256=E4NG5B4X5nsLd75YiyJY7AE0ZQ
322
322
  graphcore/transport/tests/test_api_views.py,sha256=52tsjw-e-MfY3LkSBXtauAvziJq2AXP2nxeGIYjjS4M,36044
323
323
  graphcore/transport/tests/test_channel_layer.py,sha256=fiyowHgNUj4cVuX0CXBD-crunF3xwcMdY8MTFDkxZC8,3639
324
324
  graphcore/transport/tests/test_consumers.py,sha256=BnASkNzQYNNlL71wO02hpYKK6vXaZb8a_gMWeV0zHe8,43564
325
- graphcore/transport/tests/test_resource_metadata.py,sha256=63JFpAC50PBMn9QOdJpuDtzDoKeqFtTscdEs1hsDnAk,3189
325
+ graphcore/transport/tests/test_resource_metadata.py,sha256=kVWOv_lx0cn0qiAakSS7RwOeoB90JEfWJ4I3pSQjcz0,3434
326
326
  graphcore/types/__init__.py,sha256=ggkzsrw_aXKPwFSG3FntO0gtEvp-NUEY1b3iQ3mGiUA,201
327
327
  graphcore/types/access.py,sha256=G6McXtTmSgJvec42O-vCoabQ6mp0eSvJBSvPwcEHEVI,3977
328
328
  graphcore/types/api.py,sha256=a94aX1nXHMuf6byWverLeCucEEZ0bjzkvvydMzLYxvw,2756
@@ -336,10 +336,10 @@ graphcore/types/schedules.py,sha256=4hMr6o0kJ6utbf-XSWFw_3_qkhpL3s32q6dsRdHmSIU,
336
336
  graphcore/types/strategy.py,sha256=De3z3aFC63s96SzDzNeCFXSS2L8yrmJV0ck2eEA6adw,2998
337
337
  graphcore/types/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
338
338
  graphcore/types/tests/test_entity_id.py,sha256=dvF0wLsN9aGRI0J11i__fSFC8bKQTO5Wj1oFu9-2T8Q,1885
339
- graphcore_kernel-0.2.2.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
340
- graphcore_kernel-0.2.2.dist-info/licenses/NOTICE,sha256=O2mV23MKwYlPOz9-8wsTSRNH3noH5-ie_sFFAvoOc_A,40
341
- graphcore_kernel-0.2.2.dist-info/METADATA,sha256=Dp-2k-AdGymM8uBNnDtw6nIMty0BN-5Jl0Vc2cl77RQ,3197
342
- graphcore_kernel-0.2.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
343
- graphcore_kernel-0.2.2.dist-info/entry_points.txt,sha256=PjyzUjOAsQAhWFDJvPh37PMh8lqypo_KUUDSK214j6Y,52
344
- graphcore_kernel-0.2.2.dist-info/top_level.txt,sha256=3GxRSE2Ws8H2BMLBStYy5hD2rMhuvDfOtoJ3EP-Pm3A,10
345
- graphcore_kernel-0.2.2.dist-info/RECORD,,
339
+ graphcore_kernel-0.2.3.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
340
+ graphcore_kernel-0.2.3.dist-info/licenses/NOTICE,sha256=O2mV23MKwYlPOz9-8wsTSRNH3noH5-ie_sFFAvoOc_A,40
341
+ graphcore_kernel-0.2.3.dist-info/METADATA,sha256=2HDM80o3sV8sSBOvNJy4YVULGkbbKDdRODbMy_VJElk,3197
342
+ graphcore_kernel-0.2.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
343
+ graphcore_kernel-0.2.3.dist-info/entry_points.txt,sha256=PjyzUjOAsQAhWFDJvPh37PMh8lqypo_KUUDSK214j6Y,52
344
+ graphcore_kernel-0.2.3.dist-info/top_level.txt,sha256=3GxRSE2Ws8H2BMLBStYy5hD2rMhuvDfOtoJ3EP-Pm3A,10
345
+ graphcore_kernel-0.2.3.dist-info/RECORD,,