Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm

host page blah blah

Changed files
+27 -4
who-am-i
+14
who-am-i/demo/index.html
···
··· 1 + <!doctype html> 2 + <style> 3 + body { 4 + background: #333; 5 + color: #ccc; 6 + font-family: sans-serif; 7 + } 8 + </style> 9 + 10 + <h1>hey</h1> 11 + 12 + <iframe src="http://127.0.0.1:9997/prompt" style="border: 2px solid #000; border-radius: 0.5em;" /> 13 + 14 +
+4
who-am-i/demo/serve
···
··· 1 + #!/usr/bin/env bash 2 + 3 + echo "note: you might need to access via http://127.0.0.1:8888 (not localhost) for the iframe to get its cookies" 4 + python3 -m http.server 8888
+9 -4
who-am-i/src/server.rs
··· 3 use axum::{ 4 Router, 5 extract::{FromRef, Query, State}, 6 - response::{Html, Redirect}, 7 routing::get, 8 }; 9 - use axum_extra::extract::cookie::{Cookie, Key, SignedCookieJar}; 10 11 use serde::Deserialize; 12 use std::sync::Arc; ··· 55 } 56 } 57 58 - async fn prompt(jar: SignedCookieJar) -> (SignedCookieJar, Html<String>) { 59 let m = if let Some(did) = jar.get("did") { 60 format!("oh i know you: {did}") 61 } else { ··· 89 panic!("failed to do client callback"); 90 }; 91 let did = oauth_session.did().await.expect("a did to be present"); 92 - let jar = jar.add(Cookie::new("did", did.to_string())); 93 (jar, Html(format!("sup: {did:?}"))) 94 }
··· 3 use axum::{ 4 Router, 5 extract::{FromRef, Query, State}, 6 + response::{Html, IntoResponse, Redirect}, 7 routing::get, 8 }; 9 + use axum_extra::extract::cookie::{Cookie, Key, SameSite, SignedCookieJar}; 10 11 use serde::Deserialize; 12 use std::sync::Arc; ··· 55 } 56 } 57 58 + async fn prompt(jar: SignedCookieJar) -> impl IntoResponse { 59 let m = if let Some(did) = jar.get("did") { 60 format!("oh i know you: {did}") 61 } else { ··· 89 panic!("failed to do client callback"); 90 }; 91 let did = oauth_session.did().await.expect("a did to be present"); 92 + let cookie = Cookie::build(("did", did.to_string())) 93 + .http_only(true) 94 + .secure(true) 95 + .same_site(SameSite::None) 96 + .max_age(std::time::Duration::from_secs(86_400).try_into().unwrap()); 97 + let jar = jar.add(cookie); 98 (jar, Html(format!("sup: {did:?}"))) 99 }
who-am-i/static/prompt-anon.html

This is a binary file and will not be displayed.