Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add hashed_fxa_uid to HawkPayload #1613

Merged
merged 5 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions syncserver/src/server/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ fn create_hawk_header(method: &str, port: u16, path: &str) -> String {
user_id: 42,
fxa_uid: format!("xxx_test_uid_{}", *RAND_UID),
fxa_kid: format!("xxx_test_kid_{}", *RAND_UID),
hashed_fxa_uid: format!("xxx_test_hashed_fxa_uid_{}", *RAND_UID),
hashed_device_id: "xxx_test".to_owned(),
tokenserver_origin: Default::default(),
};
Expand Down
5 changes: 5 additions & 0 deletions syncserver/src/web/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ pub struct HawkPayload {
#[serde(default)]
pub fxa_kid: String,

#[serde(default)]
pub hashed_fxa_uid: String,

#[serde(default)]
pub hashed_device_id: String,

Expand Down Expand Up @@ -156,6 +159,7 @@ impl HawkPayload {
user_id,
fxa_uid: "xxx_test".to_owned(),
fxa_kid: "xxx_test".to_owned(),
hashed_fxa_uid: "xxx_test".to_owned(),
hashed_device_id: "xxx_test".to_owned(),
tokenserver_origin: Default::default(),
}
Expand Down Expand Up @@ -508,6 +512,7 @@ mod tests {
user_id: 1,
fxa_uid: "319b98f9961ff1dbdd07313cd6ba925a".to_owned(),
fxa_kid: "de697ad66d845b2873c9d7e13b8971af".to_owned(),
hashed_fxa_uid: "0e8df5d41398a389913bd8402435649518af46493da1d4a437a46dc1784c501a".to_owned(),
hashed_device_id: "2bcb92f4d4698c3d7b083a3c698a16ccd78bc2a8d20a96e4bb128ddceaf4e0b6".to_owned(),
tokenserver_origin: Default::default(),
},
Expand Down
4 changes: 4 additions & 0 deletions syncserver/src/web/extractors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,7 @@ pub struct HawkIdentifier {
/// For NoSQL database backends that require randomly distributed primary keys
pub fxa_uid: String,
pub fxa_kid: String,
pub hashed_fxa_uid: String,
pub tokenserver_origin: TokenserverOrigin,
}

Expand All @@ -1004,6 +1005,7 @@ impl HawkIdentifier {
legacy_id: 0,
fxa_uid: "cmd".to_owned(),
fxa_kid: "cmd".to_owned(),
hashed_fxa_uid: "cmd".to_owned(),
tokenserver_origin: TokenserverOrigin::default(),
}
}
Expand Down Expand Up @@ -1106,6 +1108,7 @@ impl HawkIdentifier {
legacy_id: payload.user_id,
fxa_uid: payload.fxa_uid,
fxa_kid: payload.fxa_kid,
hashed_fxa_uid: payload.hashed_fxa_uid,
tokenserver_origin: payload.tokenserver_origin,
};
Ok(user_id)
Expand All @@ -1118,6 +1121,7 @@ impl From<HawkIdentifier> for UserIdentifier {
legacy_id: hawk_id.legacy_id,
fxa_uid: hawk_id.fxa_uid,
fxa_kid: hawk_id.fxa_kid,
hashed_fxa_uid: hawk_id.hashed_fxa_uid,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions syncstorage-db-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,5 @@ pub struct UserIdentifier {
/// For NoSQL database backends that require randomly distributed primary keys
pub fxa_uid: String,
pub fxa_kid: String,
pub hashed_fxa_uid: String,
}
1 change: 1 addition & 0 deletions syncstorage-db/src/tests/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,6 @@ pub fn hid(user_id: u32) -> UserIdentifier {
legacy_id: u64::from(user_id),
fxa_uid: format!("xxx_unit_tests_fxa_uid{}", user_id),
fxa_kid: format!("xxx_unit_tests_fxa_kid{}", user_id),
hashed_fxa_uid: format!("xxx_unit_tests_hashed_fxa_uid{}", user_id),
}
}