返回资讯中心
外部精选
软件工程
#开发者实时流

LifeCare.ID 推出健康数据授权沙盒,支持会话中途撤销访问权

来源标题:Show HN: Health agent access with personal control (revoke it mid-session)

LifeCare.ID 发布健康数据授权沙盒,让应用或 AI agent 在用户同意下读取合成健康数据,并可在会话进行中即时撤销授权。该沙盒用于验证授权、令牌、读取、记录、撤销和拒绝的完整流程;撤销后下一次请求即被拒绝,且每次访问都先写入审计日志再返回数据。

Hacker News 最新enbarca2026/11/17 · 今天30 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

The sandbox gives you identities, grants and tokens. This page is the other half: a data source that honours those tokens, so an app or an agent has something to read under consent. It serves synthetic health data and nothing else.

It is a test fixture. It exists so you can exercise the whole loop (grant, token, read, ledger entry, revoke, refusal) against something that behaves the way a conforming data source (developer access) must, before a real one is involved.

GET https://lifecare.id/sandbox-source/ describes the source and needs no token. Its configured field says whether the source has a sandbox to check tokens against; while it reads false, every data route answers 503.

It follows the resource-host contract in Data sources & connectors (developer access), with nothing cached between requests:

The record is written before the response, so an access that cannot be written to the ledger is not served. Because step 1 runs on every request, a revoked grant stops the very next call. What the source sends to LifeCare.ID® is {subject_did, scope, purpose, accessor, consent_id} and never a value; the consent_id is the one introspection returned for the token, so the ledger entry names the grant the read was made under (left out when introspection returned none).

Everything below is copy and paste. On the hosted sandbox the two self-service calls need your developer access token (see Sandbox).

SANDBOX=https://sandbox.lifecare.id SOURCE=https://lifecare.id/sandbox-source DEVACCESS=… # the token from https://app.lifecare.id/devaccess (the portal's verify page)

  1. Register a sandbox client

curl -s -X POST "$SANDBOX/v1/sandbox/clients"
-H "Authorization: Bearer $DEVACCESS" -H "Content-Type: application/json"
-d '{"name":"Pilot agent","redirect_uris":["http://127.0.0.1:4000/callback","http://localhost:4000/callback"]}' CLIENT_ID=sbx_… # client_id from the response CLIENT_SECRET=… # client_secret from the response, shown once

The redirect URI your client sends to /authorize must be one of these, byte for byte: localhost and 127.0.0.1 are different strings, and anything else is a 400 page, not a redirect. The samples below use http://127.0.0.1:4000/callback.

curl -s -X POST "$SANDBOX/v1/sandbox/test-identity"
-H "Authorization: Bearer $DEVACCESS" -H "Content-Type: application/json" -d '{}' DID=did:web:sandbox.lifecare.id:u:… # did from the response SESSION=lcs_… # session_token from the response

  1. Grant a scope

The synthetic person grants your client the recovery scope. The call carries the person's own session, which is the credential a person acts with.

curl -s -X POST "$SANDBOX/v1/consent/grant"
-H "Authorization: Bearer $SESSION" -H "Content-Type: application/json" -d '{ "subject_did":"'"$DID"'", "grantee":{"name":"Pilot agent","id":"'"$CLIENT_ID"'"}, "scopes":["recovery"], "purpose":{"text":"agent governance pilot"}, "duration_days":1}' CONSENT_ID=urn:lifecare:consent:… # consent_id from the response

A grant made through this API may name several scopes. A token is always one scope (step 4), and the authorization code flow under Discovery asks for one scope per grant. The flow reuses an identical active grant (one scope, the same purpose), so with the purpose below step 4 makes no second grant and step 7 revokes the grant the token was issued under.

An app gets its token from the authorization code flow, in the sandbox exactly as in production (D-PL4). POST /v1/token is not the app's route: a session is issued a token from it only against the person's own grant. Tokens are single scope and short lived; expires_in in the response says how long.

On the sandbox the synthetic person's yes is given headless (see Saying yes in the sandbox), then the code is exchanged with PKCE and your client credentials:

VERIFIER=$(openssl rand -base64 48 | tr '+/' '-' | tr -d '=\n') CHALLENGE=$(printf %s "$VERIFIER" | openssl dgst -sha256 -binary | openssl base64 -A | tr '+/' '-' | tr -d '=') REDIRECT=http://127.0.0.1:4000/callback RESOURCE=https://lifecare.id/sandbox-source/mcp COOKIE="__Host-lc_id_session=$SESSION"

the grant question, then the yes: post the page's hidden fields with decision=approve

PAGE=$(curl -s -b "$COOKIE" "$SANDBOX/authorize?response_type=code&client_id=$CLIENT_ID&redirect_uri=$REDIRECT&state=s1&code_challenge=$CHALLENGE&code_challenge_method=S256&scope=recovery&purpose=agent%20governance%20pilot&resource=$RESOURCE") ARGS=(); while read -r k v; do ARGS+=(--data-urlencode "$k=$v"); done < <(printf %s "$PAGE" | grep -o '<input type="hidden" name="[a-z_]" value="[^"]">' | sed 's/.name="([a-z_])" value="([^"])">/\1 \2/') CODE=$(curl -s -o /dev/null -D - -b "$COOKIE" "${ARGS[@]}" -d decision=approve "$SANDBOX/data-consent/decide" | sed -n 's/^[Ll]ocation: .[?&]code=([^&[:space:]])./\1/p') curl -s -X POST "$SANDBOX/token" -d grant_type=authorization_code -d "code=$CODE"
-d "redirect_uri=$REDIRECT" -d "code_verifier=$VERIFIER" -d "resource=$RESOURCE"
-d "client_id=$CLIENT_ID" -d "client_secret=$CLIENT_SECRET" TOKEN=lc_… # access_token from the response

  1. Read synthetic data over REST

curl -s "$SOURCE/v1/source/recovery?owner=$DID" -H "Authorization: Bearer $TOKEN"

{ "fixture": true, "notice": "Synthetic persona data from the LifeCare.ID® sandbox reference source. Not a person. Zero PHI. Test fixture.", "resource_owner": "did:web:sandbox.lifecare.id:u:817612d13f3219b6", "scope": "recovery", "purpose": "agent governance pilot", "requester": "sbx_Zy47k_NDW4E", "consent_id": "urn:lifecare:consent:8e1f…", "persona": { "persona_id": "p3-under-recovered", "display_name": "Under-Recovered Athlete", "selected_by": "did-hash" }, "as_of": "2026-10-01", "access_recorded": true, "ledger_entry_hash": "43bcec11…", "data": { "covered": true, "pillar": "recovery", "score": 0.0, "band": "off-track", "as_of": "2026-10-01", "weekly": [ { "week_index": 0, "first_day": "2026-09-02", "last_day": "2026-09-08", "covered": true, "score": 51.0, "band": "drifting", "as_of": "2026-09-08", "direction": "first-reading" } ], "sentence": "Recovery is off track: sleep is short and overnight recovery sits well below this persona's own baseline.", "sleep_label": "under-rested" } }

The read is now in the person's ledger, attributed to sandbox-source:synthetic-personas, and its payload carries the consent_id the token was issued under, so the entry links back to the grant from step 3:

curl -s "$SANDBOX/v1/consent/ledger/$DID" -H "Authorization: Bearer $SESSION"

{ "event_type": "data_access", "description": "sandbox-source:synthetic-personas read your recovery data. Purpose: agent governance pilot.", "payload": { "scope": "recovery", "purpose": "agent governance pilot", "accessor": "sandbox-source:synthetic-personas", "consent_id": "urn:lifecare:consent:8e1f…" } }

  1. Connect an MCP client

The MCP endpoint is https://lifecare.id/sandbox-source/mcp (streamable HTTP). The bearer token on the transport is the same sandbox access token. Any MCP client that can send a header will connect; for example:

{ "mcpServers": { "lifecare-sandbox-source": { "type": "http", "url": "https://lifecare.id/sandbox-source/mcp", "headers": { "Authorization": "Bearer lc_…" } } } }

A client that follows the MCP authorization specification needs no header: it starts from the 401 and asks the person, as described under Discovery, with a ready-to-run client.

curl -s -X POST "$SOURCE/mcp" -H "Authorization: Bearer $TOKEN"
-H "Content-Type: application/json" -H "Accept: application/json, text/event-stream"
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call", "params":{"name":"read_scope","arguments":{"scope":"recovery","owner":"'"$DID"'"}}}'

The tool result carries the same document as step 5, as structuredContent and as JSON text.

curl -s -X POST "$SANDBOX/v1/consent/revoke"
-H "Authorization: Bearer $SESSION" -H "Content-Type: application/json"
-d '{"consent_id":"'"$CONSENT_ID"'"}'

curl -s -i "$SOURCE/v1/source/recovery?owner=$DID" -H "Authorization: Bearer $TOKEN"

HTTP/2 401 www-authenticate: Bearer error="invalid_token", scope="recovery"

{"detail":"token inactive or unknown","error":"invalid_token"}

The MCP endpoint refuses the same token with the same 401 body, on every method. Its WWW-Authenticate challenge also carries resource_metadata, the address of its protected resource metadata (see Discovery), and the one scope it suggests (daily, or the scope a single read_scope call names).

All data routes take Authorization: Bearer <sandbox access token> and answer Cache-Control: no-store.

owner is required on every read and must be the DID the token was issued for. That is the subject check a data source owes the person, and it is never skipped.

The source follows the scope vocabulary (developer access). Each payload carries covered and a sentence; a scope a persona has no data for says so instead of inventing a reading.

told_to_guardian is not served: it is what a person tells their guardian, held by their node, and no data source holds it. A read of it answers 404 unknown_scope.

Bands are on-track, drifting and off-track; retention bands are excellent, good and watch; directions are improving, steady, declining and first-reading. Scores run from 0 to 100 and are derived, in the same sense as the node's own contract: no response field holds a reading, a mass, a percentage or a count of anything measured, and no sentence holds a digit.

Every refusal is {"detail": "...", "error": "<code>"}. Every 401 carries WWW-Authenticate: Bearer, with error="invalid_token" when a token was presented, and always scope, the one scope the source suggests: the scope the request was for when it names one (a REST read of a scope, or a single tools/call on read_scope), otherwise daily. On the MCP path the challenge also carries resource_metadata (see Discovery). A 403 insufficient_scope on the REST face carries WWW-Authenticate: Bearer error="insufficient_scope", scope="<the scope the read asked for>". On the MCP face a single tools/call for another scope is refused at the transport in the same way: HTTP 403, the same {detail, error} body, and the same header with resource_metadata added, so a client that follows the MCP authorization specification can step up (see Stepping up to another scope). Only insufficient_scope is answered that way. A call refused for its owner (wrong_subject), for a scope outside the vocabulary (unknown_scope), or for a missing owner (owner_required) is answered inside the tool result (isError: true, the same body, status as in the table). A JSON-RPC batch keeps that tool-result shape for every refusal, insufficient_scope included, because one HTTP status cannot speak for several requests. Nothing is written to the owner's ledger for a refused call.

POST https://lifecare.id/sandbox-source/mcp: streamable HTTP, stateless, JSON responses. There is no session and no server-initiated stream, so GET answers 405.

A test fixture for agent governance pilots. This is not the member MCP surface, and its tools are not a preview of one. It exists so a gateway, a firewall or a policy layer in front of an agent has a consent-bound health data server to be tested against.

This is person-managed authorization: the person, not the agent or the server, decides what an agent may read, through the flow that MCP's authorization specification describes. LifeCare.ID® is its first implementation, and Person-managed authorization is the library for both halves.

A client that follows the MCP authorization specification does not need to be told where the sandbox is. The endpoint answers a request without a valid token with 401 and a WWW-Authenticate header that carries resource_metadata, the address of its OAuth 2.0 Protected Resource Metadata (RFC 9728), and scope, one suggested scope (daily, the broadest everyday scope; it may change with the profile draft). Ask for that one, or for the one data scope you need. A stock MCP SDK uses th

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →