+14
who-am-i/demo/index.html
+14
who-am-i/demo/index.html
+4
who-am-i/demo/serve
+4
who-am-i/demo/serve
+9
-4
who-am-i/src/server.rs
+9
-4
who-am-i/src/server.rs
···
3
3
use axum::{
4
4
Router,
5
5
extract::{FromRef, Query, State},
6
-
response::{Html, Redirect},
6
+
response::{Html, IntoResponse, Redirect},
7
7
routing::get,
8
8
};
9
-
use axum_extra::extract::cookie::{Cookie, Key, SignedCookieJar};
9
+
use axum_extra::extract::cookie::{Cookie, Key, SameSite, SignedCookieJar};
10
10
11
11
use serde::Deserialize;
12
12
use std::sync::Arc;
···
55
55
}
56
56
}
57
57
58
-
async fn prompt(jar: SignedCookieJar) -> (SignedCookieJar, Html<String>) {
58
+
async fn prompt(jar: SignedCookieJar) -> impl IntoResponse {
59
59
let m = if let Some(did) = jar.get("did") {
60
60
format!("oh i know you: {did}")
61
61
} else {
···
89
89
panic!("failed to do client callback");
90
90
};
91
91
let did = oauth_session.did().await.expect("a did to be present");
92
-
let jar = jar.add(Cookie::new("did", did.to_string()));
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);
93
98
(jar, Html(format!("sup: {did:?}")))
94
99
}
who-am-i/static/prompt-anon.html
who-am-i/static/prompt-anon.html
This is a binary file and will not be displayed.