···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
···3use 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};
1011use serde::Deserialize;
12use std::sync::Arc;
···55 }
56}
5758-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()));
0000093 (jar, Html(format!("sup: {did:?}")))
94}
···3use 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};
1011use serde::Deserialize;
12use std::sync::Arc;
···55 }
56}
5758+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}