You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Over pipe transport, `ctx.auth` is always `AuthContext.anonymous()` (unauthenticated).
1247
1249
1250
+
### OAuth Discovery (RFC 9728)
1251
+
1252
+
vgi-rpc supports [RFC 9728](https://www.rfc-editor.org/rfc/rfc9728) OAuth 2.0 Protected Resource Metadata, allowing clients to automatically discover a server's authentication requirements.
1253
+
1254
+
**Server setup** — pass `OAuthResourceMetadata` to `make_wsgi_app` to serve `/.well-known/oauth-protected-resource` and include `WWW-Authenticate` headers on 401 responses:
1255
+
1256
+
```python
1257
+
from vgi_rpc import RpcServer
1258
+
from vgi_rpc.http import OAuthResourceMetadata, jwt_authenticate, make_wsgi_app
Clients can also discover auth requirements from a 401 response's `WWW-Authenticate` header using `parse_resource_metadata_url()` and `fetch_oauth_metadata()`.
1286
+
1287
+
**`jwt_authenticate()`** creates a ready-to-use `authenticate` callback that validates Bearer JWTs against a JWKS endpoint (with automatic key refresh on unknown `kid`). If `jwks_uri` is not provided, it is discovered from the issuer's `/.well-known/openid-configuration`. Requires `pip install vgi-rpc[oauth]`.
1288
+
1248
1289
### Transport metadata
1249
1290
1250
1291
`ctx.transport_metadata` provides transport-level information (e.g. `remote_addr`, `user_agent` for HTTP). This is a read-only mapping populated by the transport layer.
@@ -1329,6 +1370,7 @@ The [`examples/`](examples/) directory contains runnable scripts demonstrating k
1329
1370
|[`testing_pipe.py`](examples/testing_pipe.py)| Unit-testing with `serve_pipe()` (no network) |
1330
1371
|[`testing_http.py`](examples/testing_http.py)| Unit-testing the HTTP transport with `make_sync_client()`|
1331
1372
|[`auth.py`](examples/auth.py)| HTTP authentication with Bearer tokens and guarded methods |
1373
+
|[`oauth_discovery.py`](examples/oauth_discovery.py)| RFC 9728 OAuth discovery with JWT authentication |
1332
1374
|[`introspection.py`](examples/introspection.py)| Runtime service introspection with `enable_describe`|
1333
1375
|[`shared_memory.py`](examples/shared_memory.py)| Zero-copy shared memory transport with `ShmPipeTransport`|
0 commit comments