chadtmiller.com/group-host
atmosphere group host
0
0
Apps acting as a person reach the host through the person's PDS
crates/group-host/src/api.rs+7−5
| @@ -256,11 +256,13 @@ pub async fn did_json(State(host): State<Arc<Host>>) -> Result<Json<Value>, Stat | ||
if !did.starts_with("did:web:") { | ||
return Err(StatusCode::NOT_FOUND); | ||
} | ||
let services = [( | ||
"#atproto_pds", | ||
"AtprotoPersonalDataServer", | ||
host.config.public_url.as_str(), | ||
)]; | ||
// Its groups' PDS, and the service an app reaches through a person's | ||
// PDS, by `atproto-proxy: <did>#opensocial`, to act as them here. | ||
let url = host.config.public_url.as_str(); | ||
let services = [ | ||
("#atproto_pds", "AtprotoPersonalDataServer", url), | ||
("#opensocial", "OpensocialGroupHost", url), | ||
]; | ||
Ok(Json(atproto::did::service_document( | ||
did, | ||
&host.secrets.signing.public(), | ||
crates/group-host/tests/repos.rs+4−0
| @@ -413,6 +413,10 @@ async fn serves_its_own_did_document() { | ||
atproto::did::pds(&doc).as_deref(), | ||
Some("https://host.test") | ||
); | ||
assert_eq!( | ||
atproto::did::service(&doc, "#opensocial").as_deref(), | ||
Some("https://host.test") | ||
); | ||
| ||
let missing = h.host.plc.document("did:plc:nobody").await.unwrap_err(); | ||
assert_eq!(missing.to_string(), "no document for did:plc:nobody"); | ||
crates/opensocial/tests/commands.rs+31−0
| @@ -282,6 +282,37 @@ async fn says_what_is_wrong_with_what_it_is_asked() { | ||
} | ||
} | ||
| ||
/// An app acting as a person reaches the host through the person's own | ||
/// PDS, as `atproto-proxy` names the host's `#opensocial` service: the | ||
/// PDS signs the call for them, and the host answers it as theirs. | ||
#[tokio::test] | ||
async fn answers_a_call_a_persons_pds_proxies() { | ||
let h = host().await; | ||
let n = net(); | ||
let alice = &n.accounts[0]; | ||
let http = reqwest::Client::new(); | ||
let session: serde_json::Value = http | ||
.post(format!("{}/xrpc/com.atproto.server.createSession", n.pds)) | ||
.json(&serde_json::json!({"identifier": alice.handle, "password": alice.password})) | ||
.send() | ||
.await | ||
.unwrap() | ||
.json() | ||
.await | ||
.unwrap(); | ||
let res = http | ||
.get(format!("{}/xrpc/fyi.opensocial.getViewer", n.pds)) | ||
.header("atproto-proxy", format!("{}#opensocial", did_web(&h.url))) | ||
.bearer_auth(session["accessJwt"].as_str().unwrap()) | ||
.send() | ||
.await | ||
.unwrap(); | ||
let status = res.status(); | ||
let said: serde_json::Value = res.json().await.unwrap_or_default(); | ||
assert!(status.is_success(), "{status} {said}"); | ||
assert_eq!(said["actor"]["did"], alice.did.as_str(), "{said}"); | ||
} | ||
| ||
#[test] | ||
fn reads_its_environment() { | ||
let env = Env::from(|_| None); | ||
docs/design/signing-in.md+14−0
| @@ -29,6 +29,20 @@ refuses every cookie signed before. Every server a handle leads to is | ||
reached only at a public address, as a client's metadata is. The console | ||
forwards `/console/*` to the host, cookies and all. | ||
| ||
## Apps acting as a person | ||
| ||
An app acting as a person, not as a group (the `opensocial` command, an | ||
assistant's MCP server), calls the host's methods as that person, and the | ||
host answers them by the person's roles, as it answers the console. It | ||
signs in at the person's own PDS, never here, and either asks that PDS for | ||
a service token for each call (`com.atproto.server.getServiceAuth`), as | ||
the command does, or sends each call through it, with `atproto-proxy: | ||
<host DID>#opensocial`: the PDS signs it as the person and forwards it to | ||
the address the host's DID document names for `#opensocial`. An OAuth app | ||
asks the person's PDS for `include:fyi.opensocial.basePermissions` with | ||
the host's service as its audience, and the person sees, there, what it | ||
may do. | ||
| ||
## The server | ||
| ||
The host is a standard atproto authorization server (`oauth.rs`): | ||