Skip to content

Commit a8ffe6f

Browse files
authored
remove dead jwt field from session types (#72)
1 parent 40e7936 commit a8ffe6f

5 files changed

Lines changed: 14 additions & 66 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
Each entry lists the date and the crate versions that were released.
66

7+
## 2026-05-24 — mqdb-agent 0.8.4
8+
9+
### Removed
10+
11+
- Dead `jwt: String` field on `Session`, `NewSession`, and `SessionRef`. After 0.8.3 wired the JTI directly into the session, no code path read the stored JWT anymore: `handle_logout` uses `session.jti`, `destroy_others_by_canonical_id` returns JTIs, and `handle_ticket` mints fresh ticket JWTs from session claims rather than the stored one. The session-time JWT was never returned to the client either — callback, register, and login all set just the session-id cookie plus a user-info JSON body. Dropped the field and removed `mint_callback_jwt` entirely; its three callers now generate a JTI inline via `JtiRevocationStore::generate_jti()`. `handle_login` no longer needs to construct a `ProviderIdentity` or destructure `email_verified`. No behavior change; the affected types are crate-private.
12+
713
## 2026-05-23 — mqdb-agent 0.8.3
814

915
### Fixed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/mqdb-agent/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mqdb-agent"
3-
version = "0.8.3"
3+
version = "0.8.4"
44
edition.workspace = true
55
license = "Apache-2.0"
66
authors.workspace = true

crates/mqdb-agent/src/http/handlers.rs

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,8 @@ pub async fn handle_callback(state: &ServerState, query: &str) -> HttpResponse {
266266
persist_oauth_tokens(state, &link_key, &canonical_id, refresh_token, &identity).await;
267267
}
268268

269-
let (jwt, jti) = mint_callback_jwt(state, &canonical_id, &identity);
270-
271269
let Some(session_id) = state.session_store.create(NewSession {
272-
jwt,
273-
jti,
270+
jti: JtiRevocationStore::generate_jti(),
274271
canonical_id,
275272
provider: provider.to_string(),
276273
provider_sub: identity.provider_sub.clone(),
@@ -618,33 +615,6 @@ async fn persist_oauth_tokens(
618615
}
619616
}
620617

621-
fn mint_callback_jwt(
622-
state: &ServerState,
623-
canonical_id: &str,
624-
identity: &ProviderIdentity,
625-
) -> (String, String) {
626-
let now = std::time::SystemTime::now()
627-
.duration_since(std::time::UNIX_EPOCH)
628-
.map_or(0, |d| d.as_secs());
629-
630-
let jti = JtiRevocationStore::generate_jti();
631-
let claims = json!({
632-
"sub": canonical_id,
633-
"iss": state.jwt_config.issuer,
634-
"aud": state.jwt_config.audience,
635-
"exp": now + state.jwt_config.expiry_secs,
636-
"iat": now,
637-
"jti": jti,
638-
"email": identity.email,
639-
"name": identity.name,
640-
"picture": identity.picture,
641-
"provider": identity.provider,
642-
"provider_sub": identity.provider_sub,
643-
});
644-
645-
(sign_jwt(&claims, &state.jwt_config), jti)
646-
}
647-
648618
pub async fn handle_refresh(state: &ServerState, body: &[u8]) -> HttpResponse {
649619
let cors = state.cors_origin.as_deref();
650620

@@ -1741,10 +1711,8 @@ pub async fn handle_register(state: &ServerState, body: &[u8], client_ip: &str)
17411711
return json_response_with_credentials(500, &json!({"error": "registration failed"}), cors);
17421712
}
17431713

1744-
let (jwt, jti) = mint_callback_jwt(state, &canonical_id, &identity);
17451714
let Some(session_id) = state.session_store.create(NewSession {
1746-
jwt,
1747-
jti,
1715+
jti: JtiRevocationStore::generate_jti(),
17481716
canonical_id: canonical_id.clone(),
17491717
provider: "email".to_string(),
17501718
provider_sub,
@@ -1832,7 +1800,7 @@ pub async fn handle_login(state: &ServerState, body: &[u8], client_ip: &str) ->
18321800
return json_response_with_credentials(500, &json!({"error": "login failed"}), cors);
18331801
};
18341802

1835-
let (display_name, display_email, verified) = if let Some(mut ident) =
1803+
let (display_name, display_email) = if let Some(mut ident) =
18361804
read_entity(&state.mqtt_client, "_identities", canonical_id).await
18371805
{
18381806
if let Some(ref crypto) = state.identity_crypto {
@@ -1850,30 +1818,15 @@ pub async fn handle_login(state: &ServerState, body: &[u8], client_ip: &str) ->
18501818
.get("primary_email")
18511819
.and_then(|v| v.as_str())
18521820
.map(String::from);
1853-
let ev = ident
1854-
.get("email_verified")
1855-
.and_then(serde_json::Value::as_bool)
1856-
.unwrap_or(false);
1857-
(n, e, ev)
1821+
(n, e)
18581822
} else {
1859-
(None, Some(email.to_string()), false)
1823+
(None, Some(email.to_string()))
18601824
};
18611825

18621826
let picture = fetch_picture_from_links(state, canonical_id).await;
18631827

1864-
let identity = ProviderIdentity {
1865-
provider: "email",
1866-
provider_sub: canonical_id.to_string(),
1867-
email: display_email.clone(),
1868-
name: display_name.clone(),
1869-
picture: picture.clone(),
1870-
email_verified: verified,
1871-
};
1872-
let (jwt, jti) = mint_callback_jwt(state, canonical_id, &identity);
1873-
18741828
let Some(session_id) = state.session_store.create(NewSession {
1875-
jwt,
1876-
jti,
1829+
jti: JtiRevocationStore::generate_jti(),
18771830
canonical_id: canonical_id.to_string(),
18781831
provider: "email".to_string(),
18791832
provider_sub: canonical_id.to_string(),
@@ -2833,7 +2786,6 @@ pub async fn handle_dev_login(state: &ServerState, body: &[u8]) -> HttpResponse
28332786
}
28342787

28352788
let Some(session_id) = state.session_store.create(NewSession {
2836-
jwt: String::new(),
28372789
jti: String::new(),
28382790
canonical_id: canonical_id.clone(),
28392791
provider: "dev".to_string(),

crates/mqdb-agent/src/http/session_store.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const SESSION_ID_BYTES: usize = 32;
1111
const SESSION_TTL_SECS: u64 = 86400;
1212

1313
pub struct Session {
14-
pub jwt: String,
1514
pub jti: String,
1615
pub canonical_id: String,
1716
pub provider: String,
@@ -24,7 +23,6 @@ pub struct Session {
2423
}
2524

2625
pub struct NewSession {
27-
pub jwt: String,
2826
pub jti: String,
2927
pub canonical_id: String,
3028
pub provider: String,
@@ -61,7 +59,6 @@ impl SessionStore {
6159

6260
let session_id = hex_encode(&bytes);
6361
let session = Session {
64-
jwt: new.jwt,
6562
jti: new.jti,
6663
canonical_id: new.canonical_id,
6764
provider: new.provider,
@@ -89,7 +86,6 @@ impl SessionStore {
8986
}
9087

9188
Some(SessionRef {
92-
jwt: session.jwt.clone(),
9389
jti: session.jti.clone(),
9490
canonical_id: session.canonical_id.clone(),
9591
provider: session.provider.clone(),
@@ -170,7 +166,6 @@ impl SessionStore {
170166
}
171167

172168
pub struct SessionRef {
173-
pub jwt: String,
174169
pub jti: String,
175170
pub canonical_id: String,
176171
pub provider: String,
@@ -283,7 +278,6 @@ mod tests {
283278
let store = SessionStore::new();
284279
let session_id = store
285280
.create(NewSession {
286-
jwt: "jwt123".into(),
287281
jti: "jti-abc".into(),
288282
canonical_id: "550e8400-e29b-41d4-a716-446655440000".into(),
289283
provider: "google".into(),
@@ -297,7 +291,6 @@ mod tests {
297291
assert_eq!(session_id.len(), 64);
298292

299293
let session = store.get(&session_id).expect("get should succeed");
300-
assert_eq!(session.jwt, "jwt123");
301294
assert_eq!(session.jti, "jti-abc");
302295
assert_eq!(session.canonical_id, "550e8400-e29b-41d4-a716-446655440000");
303296
assert_eq!(session.provider, "google");
@@ -310,7 +303,6 @@ mod tests {
310303
let store = SessionStore::new();
311304
let session_id = store
312305
.create(NewSession {
313-
jwt: "jwt".into(),
314306
jti: "jti".into(),
315307
canonical_id: "canonical-1".into(),
316308
provider: "google".into(),
@@ -335,7 +327,6 @@ mod tests {
335327
fn make_session(store: &SessionStore, canonical_id: &str, jti: &str) -> String {
336328
store
337329
.create(NewSession {
338-
jwt: format!("jwt-for-{jti}"),
339330
jti: jti.into(),
340331
canonical_id: canonical_id.into(),
341332
provider: "email".into(),
@@ -395,7 +386,6 @@ mod tests {
395386
let store = SessionStore::new();
396387
let dev_session = store
397388
.create(NewSession {
398-
jwt: String::new(),
399389
jti: String::new(),
400390
canonical_id: "user-a".into(),
401391
provider: "dev".into(),

0 commit comments

Comments
 (0)