graphcore-kernel 0.2.1__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.
- graphcore/auth/authn/README.md +12 -1
- graphcore/auth/authn/resource_metadata.py +5 -2
- graphcore/transport/tests/test_api_views.py +34 -0
- graphcore/transport/tests/test_resource_metadata.py +5 -1
- graphcore/transport/urls.py +1 -0
- graphcore/transport/views.py +17 -0
- {graphcore_kernel-0.2.1.dist-info → graphcore_kernel-0.2.3.dist-info}/METADATA +1 -1
- {graphcore_kernel-0.2.1.dist-info → graphcore_kernel-0.2.3.dist-info}/RECORD +13 -13
- {graphcore_kernel-0.2.1.dist-info → graphcore_kernel-0.2.3.dist-info}/WHEEL +0 -0
- {graphcore_kernel-0.2.1.dist-info → graphcore_kernel-0.2.3.dist-info}/entry_points.txt +0 -0
- {graphcore_kernel-0.2.1.dist-info → graphcore_kernel-0.2.3.dist-info}/licenses/LICENSE +0 -0
- {graphcore_kernel-0.2.1.dist-info → graphcore_kernel-0.2.3.dist-info}/licenses/NOTICE +0 -0
- {graphcore_kernel-0.2.1.dist-info → graphcore_kernel-0.2.3.dist-info}/top_level.txt +0 -0
graphcore/auth/authn/README.md
CHANGED
|
@@ -34,8 +34,10 @@ GRAPHCORE_TRUSTED_ISSUERS = [{
|
|
|
34
34
|
'issuer': 'https://id.example.com/realms/notes', # public URL; matched against `iss`
|
|
35
35
|
'audience': 'notes', # required in `aud`
|
|
36
36
|
'internal_url': 'http://keycloak:8080/realms/notes', # optional: where this process fetches discovery and keys
|
|
37
|
+
'web_client_id': 'notes-web', # optional: the public client the web frontend signs in as
|
|
37
38
|
}]
|
|
38
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
|
|
39
41
|
```
|
|
40
42
|
|
|
41
43
|
- `issuer` and `audience` are required. An entry without both raises
|
|
@@ -45,6 +47,9 @@ GRAPHCORE_PUBLIC_URL = 'https://notes.example.com' # optional: this deplo
|
|
|
45
47
|
- `internal_url` changes only where discovery and the JWKS are fetched.
|
|
46
48
|
`iss` is always matched against the public `issuer`, and a `jwks_uri`
|
|
47
49
|
under the public URL is rewritten onto the internal one.
|
|
50
|
+
- `web_client_id` (default `graphcore-web`) and the first entry's `issuer`
|
|
51
|
+
are what `GET /graphcore/api/auth/client/` returns, unauthenticated. The
|
|
52
|
+
web frontend signs in with them, so its build names no issuer or client.
|
|
48
53
|
- Nothing names a provider. Any issuer that publishes OIDC discovery and
|
|
49
54
|
signs with RS256 works.
|
|
50
55
|
|
|
@@ -123,7 +128,7 @@ points at it:
|
|
|
123
128
|
```
|
|
124
129
|
GET /.well-known/oauth-protected-resource[/mcp]
|
|
125
130
|
{"resource": "<origin>[/mcp]", "authorization_servers": ["<issuer>", …],
|
|
126
|
-
"bearer_methods_supported": ["header"]
|
|
131
|
+
"bearer_methods_supported": ["header"]}
|
|
127
132
|
|
|
128
133
|
401 WWW-Authenticate: Bearer resource_metadata="<origin>/.well-known/oauth-protected-resource"
|
|
129
134
|
```
|
|
@@ -132,6 +137,12 @@ GET /.well-known/oauth-protected-resource[/mcp]
|
|
|
132
137
|
host, which must pass `ALLOWED_HOSTS` (localhost under `DEBUG`) so a forged
|
|
133
138
|
`Host` is never echoed.
|
|
134
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
|
+
|
|
135
146
|
Clients start from this document, never from a configured issuer URL:
|
|
136
147
|
|
|
137
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
|
-
|
|
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:
|
|
@@ -731,3 +731,37 @@ class TestAuthChallengeAndMe(TestCase):
|
|
|
731
731
|
@override_settings(ROOT_URLCONF='graphcore.urls')
|
|
732
732
|
def test_me_is_routed(self):
|
|
733
733
|
self.assertEqual(resolve('/api/auth/me/').url_name, 'api_auth_me')
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
class TestAuthClientView(TestCase):
|
|
737
|
+
def setUp(self):
|
|
738
|
+
from graphcore.auth.authn.testing import TestIssuer
|
|
739
|
+
|
|
740
|
+
self.issuer = TestIssuer()
|
|
741
|
+
|
|
742
|
+
async def _get(self, entry: dict | None = None):
|
|
743
|
+
with self.issuer.trusted(entries=[{**self.issuer.settings_entry, **(entry or {})}]):
|
|
744
|
+
return await views.api_auth_client(RequestFactory().get('/'))
|
|
745
|
+
|
|
746
|
+
async def test_names_the_issuer_and_the_configured_web_client_without_a_token(self):
|
|
747
|
+
response = await self._get({'web_client_id': 'toast-web'})
|
|
748
|
+
self.assertEqual(response.status_code, 200)
|
|
749
|
+
self.assertEqual(json.loads(response.content), {'issuer': self.issuer.issuer, 'client_id': 'toast-web'})
|
|
750
|
+
|
|
751
|
+
async def test_defaults_to_graphcore_web(self):
|
|
752
|
+
response = await self._get()
|
|
753
|
+
self.assertEqual(json.loads(response.content)['client_id'], 'graphcore-web')
|
|
754
|
+
|
|
755
|
+
async def test_only_get(self):
|
|
756
|
+
with self.issuer.trusted():
|
|
757
|
+
response = await views.api_auth_client(RequestFactory().post('/'))
|
|
758
|
+
self.assertEqual(response.status_code, 405)
|
|
759
|
+
|
|
760
|
+
@override_settings(GRAPHCORE_TRUSTED_ISSUERS=[])
|
|
761
|
+
async def test_no_issuer_is_unavailable(self):
|
|
762
|
+
response = await views.api_auth_client(RequestFactory().get('/'))
|
|
763
|
+
self.assertEqual(response.status_code, 503)
|
|
764
|
+
|
|
765
|
+
@override_settings(ROOT_URLCONF='graphcore.urls')
|
|
766
|
+
def test_is_routed(self):
|
|
767
|
+
self.assertEqual(resolve('/api/auth/client/').url_name, 'api_auth_client')
|
|
@@ -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')
|
graphcore/transport/urls.py
CHANGED
|
@@ -23,6 +23,7 @@ urlpatterns = [
|
|
|
23
23
|
path('api/execute_strategy_req/', views.api_execute_strategy_req, name='api_execute_strategy_req'),
|
|
24
24
|
|
|
25
25
|
path('api/auth/me/', views.api_auth_me, name='api_auth_me'),
|
|
26
|
+
path('api/auth/client/', views.api_auth_client, name='api_auth_client'),
|
|
26
27
|
|
|
27
28
|
path('api/invites/', views.api_create_invite, name='api_create_invite'),
|
|
28
29
|
path('api/invites/redeem/', views.api_redeem_invite, name='api_redeem_invite'),
|
graphcore/transport/views.py
CHANGED
|
@@ -10,6 +10,7 @@ from graphcore.types.identity import Principal
|
|
|
10
10
|
from graphcore.types.api import StrategyRequestPayload
|
|
11
11
|
from graphcore.types.entities import EntityFilter, Tombstone, client_view
|
|
12
12
|
from graphcore.auth.authn import authenticate, resource_metadata, strategy_tokens
|
|
13
|
+
from graphcore.auth.authn.authenticator import trusted_issuers
|
|
13
14
|
from graphcore.api.predicate_codec import decode_predicate
|
|
14
15
|
from graphcore.errors import (
|
|
15
16
|
Forbidden, InvalidQuery, InvalidRequest, NotFound, UnsupportedQuery, log_and_correlate,
|
|
@@ -17,6 +18,8 @@ from graphcore.errors import (
|
|
|
17
18
|
|
|
18
19
|
logger = logging.getLogger(__name__)
|
|
19
20
|
|
|
21
|
+
DEFAULT_WEB_CLIENT_ID = 'graphcore-web'
|
|
22
|
+
|
|
20
23
|
|
|
21
24
|
def _error_response(logger_message: str, status: int = 500) -> JsonResponse:
|
|
22
25
|
correlation_id = log_and_correlate(logger, logger_message)
|
|
@@ -73,6 +76,20 @@ async def api_auth_me(request):
|
|
|
73
76
|
})
|
|
74
77
|
|
|
75
78
|
|
|
79
|
+
async def api_auth_client(request):
|
|
80
|
+
"""Where the web frontend signs in, and as which public client: the
|
|
81
|
+
deployment's settings decide, so one frontend build works with any issuer."""
|
|
82
|
+
if request.method != 'GET':
|
|
83
|
+
return JsonResponse({'error': 'GET method required'}, status=405)
|
|
84
|
+
entry = next(iter(trusted_issuers().values()), None)
|
|
85
|
+
if entry is None:
|
|
86
|
+
return JsonResponse({'error': 'This deployment trusts no issuer'}, status=503)
|
|
87
|
+
return JsonResponse({
|
|
88
|
+
'issuer': entry['issuer'],
|
|
89
|
+
'client_id': entry.get('web_client_id') or DEFAULT_WEB_CLIENT_ID,
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
|
|
76
93
|
async def api_get_entity_directory(request):
|
|
77
94
|
if request.method != 'GET':
|
|
78
95
|
return JsonResponse({'error': 'GET method required'}, status=400)
|
|
@@ -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=
|
|
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=
|
|
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
|
|
@@ -315,14 +315,14 @@ graphcore/transport/agent_client.py,sha256=N95yQrYfIRR_uZhycGwRvdw6g8frSGRVN5qF9
|
|
|
315
315
|
graphcore/transport/channel_layer.py,sha256=swLpod2gna5DMh6JZw3jWfNPJIaRVRKatdk7TnAyjgk,2871
|
|
316
316
|
graphcore/transport/consumers.py,sha256=jLArPMKIUly148q5jY5hQSs4lpr1iB7D4R_l7nn0i9c,22321
|
|
317
317
|
graphcore/transport/routing.py,sha256=mdC7l-5AVdKPV3t4j2O6y2XmgEK6YE9QPsMbK-D5kI4,176
|
|
318
|
-
graphcore/transport/urls.py,sha256=
|
|
319
|
-
graphcore/transport/views.py,sha256=
|
|
318
|
+
graphcore/transport/urls.py,sha256=r6ar0UhSlCk-06pv-r-iH2-v6zqdHULnDTYQxkQIt64,1560
|
|
319
|
+
graphcore/transport/views.py,sha256=ldVkOk5UQNXsEEOo5oo_-DrTf1T_bJYvnr2DZTa3Gec,15242
|
|
320
320
|
graphcore/transport/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
321
321
|
graphcore/transport/tests/test_agent_client.py,sha256=E4NG5B4X5nsLd75YiyJY7AE0ZQkY0I2UbEsyf0uZEew,1294
|
|
322
|
-
graphcore/transport/tests/test_api_views.py,sha256=
|
|
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=
|
|
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.
|
|
340
|
-
graphcore_kernel-0.2.
|
|
341
|
-
graphcore_kernel-0.2.
|
|
342
|
-
graphcore_kernel-0.2.
|
|
343
|
-
graphcore_kernel-0.2.
|
|
344
|
-
graphcore_kernel-0.2.
|
|
345
|
-
graphcore_kernel-0.2.
|
|
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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|