pub struct PrivateJar<'a> { /* fields omitted */ }A child cookie jar that provides authenticated encryption for its cookies.
A private child jar signs and encrypts all the cookies added to it and
verifies and decrypts cookies retrieved from it. Any cookies stored in a
PrivateJar are simultaneously assured confidentiality, integrity, and
authenticity. In other words, clients cannot discover nor tamper with the
contents of a cookie, nor can they fabricate cookie data.
This type is only available when the secure feature is enabled.
Returns a reference to the Cookie inside this jar with the name name
and authenticates and decrypts the cookie's value, returning a Cookie
with the decrypted value. If the cookie cannot be found, or the cookie
fails to authenticate or decrypt, None is returned.
use cookie::{CookieJar, Cookie, Key};
let key = Key::generate();
let mut jar = CookieJar::new();
let mut private_jar = jar.private(&key);
assert!(private_jar.get("name").is_none());
private_jar.add(Cookie::new("name", "value"));
assert_eq!(private_jar.get("name").unwrap().value(), "value");
Adds cookie to the parent jar. The cookie's value is encrypted with
authenticated encryption assuring confidentiality, integrity, and
authenticity.
use cookie::{CookieJar, Cookie, Key};
let key = Key::generate();
let mut jar = CookieJar::new();
jar.private(&key).add(Cookie::new("name", "value"));
assert_ne!(jar.get("name").unwrap().value(), "value");
assert_eq!(jar.private(&key).get("name").unwrap().value(), "value");
Removes cookie from the parent jar.
For correct removal, the passed in cookie must contain the same path
and domain as the cookie that was initially set.
See CookieJar::remove for more
details.
use cookie::{CookieJar, Cookie, Key};
let key = Key::generate();
let mut jar = CookieJar::new();
let mut private_jar = jar.private(&key);
private_jar.add(Cookie::new("name", "value"));
assert!(private_jar.get("name").is_some());
private_jar.remove(Cookie::named("name"));
assert!(private_jar.get("name").is_none());
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Mutably borrows from an owned value. Read more