~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The host moves an account here for someone signed in to the console

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/account-move
crates/group-host/src/account_move.rsnew+577−0
577 lines changed: not loaded until asked for.
crates/group-host/src/console_login.rs+52−14
@@ -45,6 +45,8 @@ const TAKES: i64 = 15 * 60_000;
#[derive(Debug, Clone, PartialEq)]
pub struct Pending {
pub did: String,
/// Their PDS, as their DID document named it.
pub pds: String,
pub issuer: String,
pub token_endpoint: String,
pub revocation_endpoint: Option<String>,
@@ -54,6 +56,9 @@ pub struct Pending {
/// The page to go back to.
pub back: String,
pub started: i64,
/// For a sign-in to an account being moved here, who is moving it:
/// its tokens are kept for them, and the browser is not signed in.
pub mover: Option<String>,
}
impl Store {
@@ -75,7 +80,9 @@ impl Store {
p.key,
p.verifier,
p.back,
p.started
p.started,
p.mover,
p.pds
];
conn.execute(START_LOGIN, values)?;
Ok(())
@@ -95,6 +102,8 @@ impl Store {
verifier: r.get(5)?,
back: r.get(6)?,
started: r.get(7)?,
mover: r.get(8)?,
pds: r.get(9)?,
})
});
Ok(found.optional()?)
@@ -116,8 +125,8 @@ impl Store {
}
}
const START_LOGIN: &str = "INSERT INTO console_login (state, did, issuer, token_endpoint, revocation_endpoint, key, verifier, back, started) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)";
const FINISH_LOGIN: &str = "DELETE FROM console_login WHERE state = ?1 AND started > ?2 RETURNING did, issuer, token_endpoint, revocation_endpoint, key, verifier, back, started";
const START_LOGIN: &str = "INSERT INTO console_login (state, did, issuer, token_endpoint, revocation_endpoint, key, verifier, back, started, mover, pds) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)";
const FINISH_LOGIN: &str = "DELETE FROM console_login WHERE state = ?1 AND started > ?2 RETURNING did, issuer, token_endpoint, revocation_endpoint, key, verifier, back, started, mover, pds";
const SIGN_OUT: &str =
"INSERT INTO console_logout (did, at) VALUES (?1, ?2) ON CONFLICT (did) DO UPDATE SET at = ?2";
@@ -175,7 +184,7 @@ impl Host {
format!("{}/console/client-metadata.json", self.config.console_url)
}
fn console_callback(&self) -> String {
pub(crate) fn console_callback(&self) -> String {
format!("{}/console/callback", self.config.console_url)
}
@@ -219,7 +228,7 @@ impl Host {
/// Sends `form` to `url` from the console's client, with a DPoP proof
/// of `key` and its assertion for `issuer`, once more with the nonce
/// the server asks for. The JSON answered, if it took it.
async fn console_post(
pub(crate) async fn console_post(
&self,
url: &str,
issuer: &str,
@@ -282,9 +291,9 @@ impl Host {
Err(format!("{url} asked for a nonce twice"))
}
/// Where `identifier`, a handle or DID, signs in: their DID and their
/// PDS's authorization server's metadata.
async fn sign_in_at(&self, identifier: &str) -> Result<(String, Value), String> {
/// Where `identifier`, a handle or DID, signs in: their DID, their PDS,
/// and its authorization server's metadata.
async fn sign_in_at(&self, identifier: &str) -> Result<(String, String, Value), String> {
let identifier = identifier.trim().trim_start_matches('@').to_lowercase();
let did = match identifier.starts_with("did:") {
true => Some(identifier.clone()),
@@ -318,7 +327,7 @@ impl Host {
if server["issuer"] != issuer {
return Err(format!("{issuer} calls itself {}", server["issuer"]));
}
Ok((did, server))
Ok((did, pds, server))
}
}
@@ -333,7 +342,7 @@ pub async fn client_metadata(State(host): State<Arc<Host>>) -> Json<Value> {
"client_name": "Group host",
"client_uri": host.config.console_url,
"redirect_uris": [host.console_callback()],
"scope": "atproto",
"scope": format!("atproto {}", host.move_scope()),
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"],
"token_endpoint_auth_method": "private_key_jwt",
@@ -349,11 +358,22 @@ pub async fn client_metadata(State(host): State<Arc<Host>>) -> Json<Value> {
pub async fn login(
State(host): State<Arc<Host>>,
Query(q): Query<HashMap<String, String>>,
) -> Result<Response, XrpcError> {
sign_in(&host, &q, "atproto", None).await
}
/// Starts a sign-in to `q`'s `handle`, asking for `scope`, for `mover`
/// where it is an account they are moving here.
pub(crate) async fn sign_in(
host: &Host,
q: &HashMap<String, String>,
scope: &str,
mover: Option<String>,
) -> Result<Response, XrpcError> {
let Some(identifier) = q.get("handle").filter(|h| !h.trim().is_empty()) else {
return Ok(failed(StatusCode::BAD_REQUEST, "say who you are"));
};
let (did, server) = match host.sign_in_at(identifier).await {
let (did, pds, server) = match host.sign_in_at(identifier).await {
Ok(found) => found,
Err(why) => return Ok(failed(StatusCode::BAD_REQUEST, why)),
};
@@ -368,7 +388,7 @@ pub async fn login(
("code_challenge", challenge.as_str()),
("code_challenge_method", "S256"),
("redirect_uri", callback.as_str()),
("scope", "atproto"),
("scope", scope),
("state", state.as_str()),
("login_hint", identifier.as_str()),
];
@@ -402,6 +422,7 @@ pub async fn login(
let now = now_millis();
let pending = Pending {
did,
pds,
issuer,
token_endpoint: text("token_endpoint"),
revocation_endpoint: server["revocation_endpoint"].as_str().map(String::from),
@@ -409,11 +430,12 @@ pub async fn login(
verifier,
back: back_to(q.get("back")),
started: now,
mover,
};
host.store
.start_login(&state, &pending, now)
.map_err(XrpcError::internal)?;
let started = cookie(&host, STARTED, &state, TAKES / 1000);
let started = cookie(host, STARTED, &state, TAKES / 1000);
Ok(([(header::SET_COOKIE, started)], Redirect::to(to.as_str())).into_response())
}
@@ -468,6 +490,23 @@ pub async fn callback(
let why = format!("signed in as {}, not {}", tokens["sub"], p.did);
return Ok(failed(StatusCode::FORBIDDEN, why));
}
let done = cookie(&host, STARTED, "", 0);
// An account being moved here: its tokens kept for the one moving it,
// still signed in, and this browser signed in as nobody new.
if let Some(mover) = &p.mover {
let caller = host.console_caller(&headers).map_err(XrpcError::internal)?;
if caller.as_ref() != Some(mover) {
return Ok(failed(
StatusCode::FORBIDDEN,
"sign in to the console again first",
));
}
host.keep_move(&p, &tokens)
.await
.map_err(XrpcError::internal)?;
tracing::info!(did = p.did, mover, "signed in to an account to move");
return Ok(([(header::SET_COOKIE, done)], Redirect::to(&p.back)).into_response());
}
// Knowing who they are is all the host wanted: it keeps nothing.
if let (Some(url), Some(token)) = (&p.revocation_endpoint, tokens["access_token"].as_str()) {
let revoked = host
@@ -482,7 +521,6 @@ pub async fn callback(
&host.session_cookie(&p.did, now),
LASTS / 1000,
);
let done = cookie(&host, STARTED, "", 0);
tracing::info!(did = p.did, "signed in to the console");
let headers = AppendHeaders([(header::SET_COOKIE, session), (header::SET_COOKIE, done)]);
Ok((headers, Redirect::to(&p.back)).into_response())
crates/group-host/src/import.rs+140−110
@@ -404,73 +404,87 @@ pub async fn import_account(
Json(body): Json<Value>,
) -> Answer {
let me = signed_in(&host, &headers, &format!("{NS}.importAccount")).await?;
if !host.may_found(&me) {
return Err(XrpcError::new(
StatusCode::FORBIDDEN,
"NotAllowed",
"this host is not starting groups for you",
));
}
let jwt = body["serviceJwt"].as_str();
let jwt = jwt.ok_or_else(|| invalid("serviceJwt is required"))?;
let did = proof(&host, jwt).await?;
if did == me {
return Err(refused(
"SameAccount",
"sign in with your own account, not the one becoming the group",
));
}
let started = host.store.pending_import(&did);
let here = host.store.account(&did).map_err(XrpcError::internal)?;
match started.map_err(XrpcError::internal)? {
Some(p) if p.founder != me => {
let started = host.import_as(&me, jwt, body["address"].as_str()).await?;
Ok(Json(started))
}
impl Host {
/// Starts moving the account `jwt` is the word of here, for `me`, at
/// `address` if asked: what importAccount answers.
pub(crate) async fn import_as(
&self,
me: &str,
jwt: &str,
address: Option<&str>,
) -> Result<Value, XrpcError> {
if !self.may_found(me) {
return Err(XrpcError::new(
StatusCode::FORBIDDEN,
"NotAllowed",
"this host is not starting groups for you",
));
}
let did = proof(self, jwt).await?;
if did == me {
return Err(refused(
"AlreadyHere",
"someone else is moving this account here",
"SameAccount",
"sign in with your own account, not the one becoming the group",
));
}
Some(_) => host.forget(&did),
None if here.is_some() => {
return Err(refused("AlreadyHere", "this host has that account already"));
let started = self.store.pending_import(&did);
let here = self.store.account(&did).map_err(XrpcError::internal)?;
match started.map_err(XrpcError::internal)? {
Some(p) if p.founder != me => {
return Err(refused(
"AlreadyHere",
"someone else is moving this account here",
));
}
Some(_) => self.forget(&did),
None if here.is_some() => {
return Err(refused("AlreadyHere", "this host has that account already"));
}
None => {}
}
None => {}
}
let plan = host.plan_import(&did, body["address"].as_str()).await?;
if let Some(e) = plan.refused {
return Err(e);
}
let account = take_in(&host, &did, &plan.handle, &plan.address).await?;
let off = host.store.deactivate(&did, now_millis(), &me, &[], &[]);
off.map_err(XrpcError::internal)?;
let (records, blobs, profile) = match host.copy(&did, &plan).await {
Ok(copied) => copied,
Err(e) => {
// Nothing half copied stays.
host.forget(&did);
let plan = self.plan_import(&did, address).await?;
if let Some(e) = plan.refused {
return Err(e);
}
};
let named = profile["displayName"].as_str().map(str::trim);
let display_name = named.filter(|n| !n.is_empty()).unwrap_or(&plan.label);
let description = profile["description"].as_str();
let description = description.map(|d| d.chars().take(DESCRIPTION_MAX).collect());
let pending = Pending {
founder: me,
display_name: display_name.into(),
description,
};
let kept = host.store.start_import(&did, &pending, now_millis());
kept.map_err(XrpcError::internal)?;
tracing::info!(did, records, blobs, "an account copied here, switched off");
Ok(Json(json!({
"did": did,
"handle": plan.handle,
"address": plan.address,
"displayName": pending.display_name,
"records": records,
"blobs": blobs,
"recommendedCreds": creds(&host, &account),
})))
let account = take_in(self, &did, &plan.handle, &plan.address).await?;
let off = self.store.deactivate(&did, now_millis(), me, &[], &[]);
off.map_err(XrpcError::internal)?;
let (records, blobs, profile) = match self.copy(&did, &plan).await {
Ok(copied) => copied,
Err(e) => {
// Nothing half copied stays.
self.forget(&did);
return Err(e);
}
};
let named = profile["displayName"].as_str().map(str::trim);
let display_name = named.filter(|n| !n.is_empty()).unwrap_or(&plan.label);
let description = profile["description"].as_str();
let description = description.map(|d| d.chars().take(DESCRIPTION_MAX).collect());
let pending = Pending {
founder: me.to_string(),
display_name: display_name.into(),
description,
};
let kept = self.store.start_import(&did, &pending, now_millis());
kept.map_err(XrpcError::internal)?;
tracing::info!(did, records, blobs, "an account copied here, switched off");
Ok(json!({
"did": did,
"handle": plan.handle,
"address": plan.address,
"displayName": pending.display_name,
"records": records,
"blobs": blobs,
"recommendedCreds": creds(self, &account),
}))
}
}
/// Whether `signed` gives `account` to this host, as importAccount said
@@ -505,55 +519,71 @@ pub async fn complete_import(
let me = signed_in(&host, &headers, &format!("{NS}.completeImport")).await?;
let did = body["did"].as_str();
let did = did.ok_or_else(|| invalid("did is required"))?;
let pending = host
.store
.pending_import(did)
.map_err(XrpcError::internal)?;
let Some(pending) = pending.filter(|p| p.founder == me) else {
return Err(refused("NotFound", "no move of that account here of yours"));
};
let account = host.store.account(did).map_err(XrpcError::internal)?;
let account = account.expect("a move's account");
let signed = Signed::from_json(&body["operation"]).ok();
let Some(signed) = signed.filter(|s| gives_here(&host, &account, s)) else {
return Err(refused(
"InvalidOperation",
"the signed operation does not give the account to this host",
));
};
// The directory may have it already: sent by the account's server, or
// by a try of this that failed after sending it. It is not sent again.
let last = host.plc.last_op(did).await.ok().map(|op| op.cid());
let sent = match last == Some(signed.cid()) {
true => Ok(()),
false => host.plc.publish(did, &signed).await,
};
sent.map_err(|e| {
refused(
"InvalidOperation",
format!("the directory refused it: {e:#}"),
)
})?;
let on = host.activate_arrived(did, &account.handle);
on.map_err(XrpcError::internal)?;
host.tell_spaces(did).await.map_err(XrpcError::internal)?;
let group = NewGroup {
handle: account.handle.clone(),
founder: me.clone(),
display_name: pending.display_name,
description: pending.description,
..NewGroup::default()
};
let made = host.make_group(did, &group).await?;
host.store.end_import(did).map_err(XrpcError::internal)?;
let logged = host.record(did, &me, None, "moved the account here as a group");
logged.map_err(XrpcError::internal)?;
let address = host.store.address(did).map_err(XrpcError::internal)?;
Ok(Json(json!({
"did": did,
"handle": account.handle,
"address": address,
"meta": made.meta,
"members": made.members,
})))
let done = host
.complete_import_as(&me, did, &body["operation"])
.await?;
Ok(Json(done))
}
impl Host {
/// Finishes `me`'s move of `did` with `operation`, its old server's
/// signature: what completeImport answers.
pub(crate) async fn complete_import_as(
&self,
me: &str,
did: &str,
operation: &Value,
) -> Result<Value, XrpcError> {
let pending = self
.store
.pending_import(did)
.map_err(XrpcError::internal)?;
let Some(pending) = pending.filter(|p| p.founder == me) else {
return Err(refused("NotFound", "no move of that account here of yours"));
};
let account = self.store.account(did).map_err(XrpcError::internal)?;
let account = account.expect("a move's account");
let signed = Signed::from_json(operation).ok();
let Some(signed) = signed.filter(|s| gives_here(self, &account, s)) else {
return Err(refused(
"InvalidOperation",
"the signed operation does not give the account to this host",
));
};
// The directory may have it already: sent by the account's server, or
// by a try of this that failed after sending it. It is not sent again.
let last = self.plc.last_op(did).await.ok().map(|op| op.cid());
let sent = match last == Some(signed.cid()) {
true => Ok(()),
false => self.plc.publish(did, &signed).await,
};
sent.map_err(|e| {
refused(
"InvalidOperation",
format!("the directory refused it: {e:#}"),
)
})?;
let on = self.activate_arrived(did, &account.handle);
on.map_err(XrpcError::internal)?;
self.tell_spaces(did).await.map_err(XrpcError::internal)?;
let group = NewGroup {
handle: account.handle.clone(),
founder: me.to_string(),
display_name: pending.display_name,
description: pending.description,
..NewGroup::default()
};
let made = self.make_group(did, &group).await?;
self.store.end_import(did).map_err(XrpcError::internal)?;
let logged = self.record(did, me, None, "moved the account here as a group");
logged.map_err(XrpcError::internal)?;
let address = self.store.address(did).map_err(XrpcError::internal)?;
Ok(json!({
"did": did,
"handle": account.handle,
"address": address,
"meta": made.meta,
"members": made.members,
}))
}
}
crates/group-host/src/import_space.rs+6−2
@@ -180,7 +180,7 @@ impl Store {
impl Host {
/// A space `did` governs, from its meta archive: kept here as this
/// host would keep it, replacing what an earlier try kept.
fn import_space_meta(&self, did: &str, bytes: &[u8]) -> Result<String, XrpcError> {
pub(crate) fn import_space_meta(&self, did: &str, bytes: &[u8]) -> Result<String, XrpcError> {
let meta = read_space_meta(bytes);
let meta = meta.map_err(|e| refused("InvalidArchive", e.to_string()))?;
let space = SpaceRef::parse(&meta.space).expect("a space the archive's reader checked");
@@ -214,7 +214,11 @@ impl Host {
/// `did`'s repo in a space, from its STAR archive once its records are
/// what its commit says: kept here in place of what an earlier try
/// kept, less any record this host would not keep. How many it kept.
fn import_space_repo(&self, did: &str, bytes: &[u8]) -> Result<(String, usize), XrpcError> {
pub(crate) fn import_space_repo(
&self,
did: &str,
bytes: &[u8],
) -> Result<(String, usize), XrpcError> {
let read = read_star(bytes).map_err(|e| refused("InvalidArchive", e.to_string()));
let (commit, records) = read?;
if commit.repo != did {
crates/group-host/src/lib.rs+22−1
@@ -3,6 +3,7 @@
//! `fyi.opensocial.*` methods that run a group. `docs/design/README.md`
//! says how it is built and what is still to come.
pub mod account_move;
pub mod actors;
pub mod api;
pub mod app_passwords;
@@ -442,6 +443,23 @@ pub fn router(host: Arc<Host>) -> Router {
get(console_login::client_metadata),
)
.route("/console/login", get(console_login::login))
.route("/console/move/login", get(account_move::login))
.route(
"/xrpc/fyi.opensocial.getAccountMove",
get(account_move::get_account_move),
)
.route(
"/xrpc/fyi.opensocial.startAccountMove",
post(account_move::start_account_move),
)
.route(
"/xrpc/fyi.opensocial.finishAccountMove",
post(account_move::finish_account_move),
)
.route(
"/xrpc/fyi.opensocial.cancelAccountMove",
post(account_move::cancel_account_move),
)
.route("/console/callback", get(console_login::callback))
.route("/console/logout", post(console_login::logout))
.merge(token_routes())
@@ -598,12 +616,15 @@ pub async fn serve(config: Config) -> anyhow::Result<()> {
println!("listening on {}", listener.local_addr()?);
tracing::info!(public_url = %config.public_url, did = %config.service_did, "serving");
let host = Arc::new(Host::open(config)?);
// Uploads no record took, swept now and each hour after.
// Uploads no record took, and moves kept a day, swept now and each
// hour after.
let sweeping = host.clone();
tokio::spawn(async move {
loop {
let swept = sweeping.sweep_blobs(time::now_millis());
tracing::info!(?swept, "swept the uploads no record took");
let moves = sweeping.sweep_moves(time::now_millis()).await;
tracing::info!(?moves, "gave back the moves kept a day");
tokio::time::sleep(std::time::Duration::from_secs(60 * 60)).await;
}
});
crates/group-host/src/store.rs+17−0
@@ -377,6 +377,23 @@ pub const MIGRATIONS: &[&str] = &[
used_at INTEGER NOT NULL
);
CREATE INDEX assistant_grant_member ON assistant_grant (grp, member);
",
"
ALTER TABLE console_login ADD COLUMN mover TEXT;
ALTER TABLE console_login ADD COLUMN pds TEXT NOT NULL DEFAULT '';
CREATE TABLE account_move (
mover TEXT PRIMARY KEY,
did TEXT NOT NULL,
pds TEXT NOT NULL,
issuer TEXT NOT NULL,
token_endpoint TEXT NOT NULL,
revocation_endpoint TEXT,
key BLOB NOT NULL,
access TEXT NOT NULL,
refresh TEXT,
expires_at INTEGER NOT NULL,
started INTEGER NOT NULL
);
",
];
crates/group-host/tests/account_move.rsnew+770−0
770 lines changed: not loaded until asked for.
crates/opensocial/src/lib.rs+11−14
@@ -541,22 +541,23 @@ async fn start_import(
}
let copied = me.call(host, &m("importAccount"), &body).await?;
let mut out = format!(
"moving {did}
from {}
as {}
",
"moving {did}\n from {}\n as {}\n",
text(&plan["pds"]),
text(&copied["handle"])
);
out += &format!(
"copied {} records, {} files
",
"copied {} records, {} files\n",
copied["records"], copied["blobs"]
);
// Each space it governs or wrote in: a space it governs first, then its
// files there, then its repo, which holds them.
let mut spaces = Vec::new();
let mut cursor = Some(String::new());
// Only a server that says it holds spaces has any to bring.
let described = theirs
.own("com.atproto.server.describeServer", &[], None)
.await?;
let holds = described["spacesAlpha"] == true;
let mut cursor = holds.then_some(String::new());
while let Some(after) = cursor.take() {
let mut page = vec![("limit", "100")];
page.extend((!after.is_empty()).then_some(("cursor", after.as_str())));
@@ -605,16 +606,13 @@ async fn start_import(
}
}
out += &format!(
"brought {} spaces: {records} records, {files} files
",
"brought {} spaces: {records} records, {files} files\n",
spaces.len()
);
let ask = "com.atproto.identity.requestPlcOperationSignature";
theirs.own(ask, &[], Some(&Value::Null)).await?;
out += &format!(
"its server has emailed a code to move its identity; finish with
opensocial import {account} --code <code>
"
"its server has emailed a code to move its identity; finish with\n opensocial import {account} --code <code>\n"
);
Ok(out)
}
@@ -637,8 +635,7 @@ async fn finish_import(
let body = json!({ "did": did, "operation": signed["operation"] });
let done = me.call(host, &m("completeImport"), &body).await?;
Ok(format!(
"moved: {} is a group here, run by you
",
"moved: {} is a group here, run by you\n",
text(&done["handle"])
))
}
docs/design/moving.md+28−0
@@ -103,6 +103,27 @@ confirms it (an emailed code, on the reference PDS).
The old server keeps its copy until its owner deletes it there; once the
DID names this host, the network reads the account here.
## Moving one from the console
`account_move.rs` walks through the same steps for someone signed in to
the console. They sign in to the account at its own server too
([signing in](signing-in.md#signing-in-to-an-account-being-moved)), and
the host, holding its tokens for them, does each step itself:
- **`getAccountMove`**: the account signed in for them to move, if any,
and whether its move is started.
- **`startAccountMove`**: the account's token for this host, from its
server; the copy, as `importAccount` makes it; its spaces, as
`importAccountSpace` takes them; and its server asked to email the
code that lets its identity move. Started again, it starts over.
- **`finishAccountMove`**: with the code, its server signs the operation,
and the move finishes as `completeImport` does. Its tokens are given
back.
- **`cancelAccountMove`**: its tokens given back and forgotten, and a copy
not yet finished discarded.
## Moving one with the command
`opensocial import <account>` walks through it, signed in as the person
moving it and, with its own password, as the account at its server (its
server signs its identity over for no app password). It copies the
@@ -112,6 +133,13 @@ and finishes.
## Its spaces
Spaces come only from a server that says it holds them
(`describeServer`'s `spacesAlpha`, as the space alpha's servers say):
most do not yet, and answer for a method they lack in no one way, so an
account on one moves with nothing more to bring. A server that fails to
say stops the move, before its identity moves, rather than leave its
spaces behind.
Between steps 2 and 3, the one moving it brings its spaces, with
**`importAccountSpace`** (`import_space.rs`). Only the account, signed in
at its server, may export them, so they come as that server serves
docs/design/README.md+3−1
@@ -125,7 +125,9 @@ says otherwise.
[recovery](recovery.md)); moving a group to another host
(`migration.rs`; done, see [moving](moving.md)); an account on
another server becoming a group, its spaces with it (`import.rs`,
`import_space.rs`; done, see [moving](moving.md#an-account-becoming-a-group)); and
`import_space.rs`; done, see [moving](moving.md#an-account-becoming-a-group)),
moved from the console by the host signed in to it (`account_move.rs`;
done, its page next); and
moving the host itself (`move_host.rs`; done, see
[moving](moving.md#moving-the-host)):
`methods/{moderation,recovery,importAccount,migration}.ts`,
docs/design/signing-in.md+22−0
@@ -29,6 +29,28 @@ 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.
## Signing in to an account being moved
Moving an account here from the console takes a second sign-in, to that
account at its own server, by someone already signed in to the console
(`/console/move/login`, `account_move.rs`). The host asks it for what a
move needs and no more: `atproto`, a `createAccount` service token for
this host's `#opensocial` service, `identity:*`, and reading its own
repos and files in spaces (`space:*?authority=*&action=read_self`).
The browser stays signed in as the person moving it, and a sign-in that
comes back to a browser no longer signed in as them is refused.
Unlike their own sign-in, the host keeps these tokens: one account per
person, for a day at most, while it does the move's steps itself
([moving](moving.md#moving-one-from-the-console)). Its calls to the account's
server are DPoP-bound to a key it made for the sign-in, take the nonce
the server asks for, and refresh the token before it lapses or once it
is refused as lapsed; one with no refresh token asks them to sign in to
the account again. The tokens are given back to the server, and
forgotten here, when the move finishes, when it is cancelled, when the
person signs in to another account to move, and, by the host's hourly
sweep, once a day has passed.
## Apps acting as a person
An app acting as a person, not as a group (the `opensocial` command, an
lexicons/fyi/opensocial/cancelAccountMove.jsonnew+23−0
@@ -0,0 +1,23 @@
{
"lexicon": 1,
"id": "fyi.opensocial.cancelAccountMove",
"defs": {
"main": {
"type": "procedure",
"description": "Stop moving the account the caller signed in to move: its tokens are given back to its server and forgotten here, and a copy of it not yet finished is discarded.",
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"properties": {}
}
},
"errors": [
{
"name": "NotFound",
"description": "No account is signed in for the caller to move."
}
]
}
}
}
lexicons/fyi/opensocial/finishAccountMove.jsonnew+77−0
lexicons/fyi/opensocial/getAccountMove.jsonnew+36−0
lexicons/fyi/opensocial/startAccountMove.jsonnew+109−0