diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2022-12-19 20:00:22 -0800 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2022-12-19 20:21:32 -0800 |
commit | 1d7431552be8ba96c58477f7743f0f875c317b8c (patch) | |
tree | 9a1b64e4c60289b0ff6afac0c6b2a1a56fcd3e51 /adenosine-pds/src | |
parent | a0d99343e164516a5d6dfe814170178580adad3f (diff) | |
download | adenosine-1d7431552be8ba96c58477f7743f0f875c317b8c.tar.gz adenosine-1d7431552be8ba96c58477f7743f0f875c317b8c.zip |
pds: implement com.atproto.session.refresh
Diffstat (limited to 'adenosine-pds/src')
-rw-r--r-- | adenosine-pds/src/lib.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/adenosine-pds/src/lib.rs b/adenosine-pds/src/lib.rs index d40058e..c9f9e0a 100644 --- a/adenosine-pds/src/lib.rs +++ b/adenosine-pds/src/lib.rs @@ -599,6 +599,29 @@ fn xrpc_post_handler( &keypair )?)) } + "com.atproto.session.refresh" => { + // actually just returns current session, because we don't implement refresh + let mut srv = srv.lock().unwrap(); + let did = xrpc_check_auth_header(&mut srv, request, None)?; + let header = request + .header("Authorization") + .ok_or(XrpcError::Forbidden("require auth header".to_string()))?; + if !header.starts_with("Bearer ") { + Err(XrpcError::Forbidden("require bearer token".to_string()))?; + } + let jwt = header.split(' ').nth(1).unwrap(); + let handle = srv + .atp_db + .resolve_did(&did)? + .expect("DID matches to a handle"); + + Ok(json!(AtpSession { + did: did.to_string(), + name: handle.to_string(), + accessJwt: jwt.to_string(), + refreshJwt: jwt.to_string(), + })) + } "com.atproto.session.delete" => { let mut srv = srv.lock().unwrap(); let _did = xrpc_check_auth_header(&mut srv, request, None)?; |