Skip to content

Commit d123ae1

Browse files
author
Bennett Hardwick
committed
Support plaintext sk
1 parent 935947b commit d123ae1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/crypto/sealed.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,15 @@ impl Sealed {
5656
let unprotected = T::plaintext_attributes()
5757
.into_iter()
5858
.map(|name| {
59+
let attr = match name {
60+
"sk" => "__sk",
61+
_ => name,
62+
};
63+
5964
self.inner()
6065
.attributes
61-
.get(name)
62-
.ok_or(SealError::MissingAttribute(name.to_string()))
66+
.get(attr)
67+
.ok_or(SealError::MissingAttribute(attr.to_string()))
6368
})
6469
.collect::<Result<Vec<&TableAttribute>, SealError>>()?;
6570

@@ -127,7 +132,13 @@ impl TryFrom<Sealed> for HashMap<String, AttributeValue> {
127132
}
128133

129134
item.0.attributes.into_iter().for_each(|(k, v)| {
130-
map.insert(k.to_string(), v.into());
135+
map.insert(
136+
match k.as_str() {
137+
"sk" => "__sk".to_string(),
138+
_ => k,
139+
},
140+
v.into(),
141+
);
131142
});
132143

133144
Ok(map)

tests/pk_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub struct User {
1515

1616
#[cryptonamo(query = "prefix", compound = "pk#sk")]
1717
#[cryptonamo(query = "prefix")]
18+
#[cryptonamo(plaintext)]
1819
#[sort_key]
1920
pub sk: String,
2021

0 commit comments

Comments
 (0)