update cookie dep

This commit is contained in:
Nikolay Kim 2021-03-06 16:39:37 +06:00
parent 94cc4b8ce1
commit bb3816f002
7 changed files with 19 additions and 16 deletions

View file

@ -16,6 +16,6 @@ name = "ntex_cors"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
ntex = "0.3.2" ntex = "0.3.5"
derive_more = "0.99.11" derive_more = "0.99.11"
futures = "0.3.13" futures = "0.3.13"

View file

@ -18,7 +18,7 @@ name = "ntex_files"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
ntex = "0.3.2" ntex = "0.3.5"
bitflags = "1.2" bitflags = "1.2"
futures = "0.3" futures = "0.3"
derive_more = "0.99.11" derive_more = "0.99.11"
@ -27,7 +27,7 @@ log = "0.4"
mime = "0.3" mime = "0.3"
mime_guess = "2.0.1" mime_guess = "2.0.1"
percent-encoding = "2.1" percent-encoding = "2.1"
v_htmlescape = "0.4" v_htmlescape = "0.13"
[dev-dependencies] [dev-dependencies]
ntex = { version = "0.3.2", features=["openssl", "compress"] } ntex = { version = "0.3.5", features=["openssl", "compress"] }

View file

@ -21,10 +21,10 @@ default = ["cookie-policy"]
cookie-policy = ["cookie/secure", "ntex/cookie"] cookie-policy = ["cookie/secure", "ntex/cookie"]
[dependencies] [dependencies]
ntex = "0.3.2" ntex = "0.3.5"
futures = "0.3.13" futures = "0.3.13"
serde = "1.0" serde = "1.0"
serde_json = "1.0" serde_json = "1.0"
cookie = "0.14.2"
derive_more = "0.99.11" derive_more = "0.99.11"
cookie = { version = "0.15", features = ["private"] }
time = { version = "0.2.5", default-features = false, features = ["std"] } time = { version = "0.2.5", default-features = false, features = ["std"] }

View file

@ -393,10 +393,10 @@ impl<Err: ErrorRenderer> CookieIdentityInner<Err> {
let mut jar = CookieJar::new(); let mut jar = CookieJar::new();
let key = if self.legacy_supported() { &self.key } else { &self.key_v2 }; let key = if self.legacy_supported() { &self.key } else { &self.key_v2 };
if add_cookie { if add_cookie {
jar.private(&key).add(cookie); jar.private_mut(&key).add(cookie);
} else { } else {
jar.add_original(cookie.clone()); jar.add_original(cookie.clone());
jar.private(&key).remove(cookie); jar.private_mut(&key).remove(cookie);
} }
for cookie in jar.delta() { for cookie in jar.delta() {
let val = HeaderValue::from_str(&cookie.to_string()).map_err(HttpError::from)?; let val = HeaderValue::from_str(&cookie.to_string()).map_err(HttpError::from)?;
@ -761,7 +761,7 @@ mod tests {
fn legacy_login_cookie(identity: &'static str) -> Cookie<'static> { fn legacy_login_cookie(identity: &'static str) -> Cookie<'static> {
let mut jar = CookieJar::new(); let mut jar = CookieJar::new();
jar.private(&Key::derive_from(&COOKIE_KEY_MASTER)) jar.private_mut(&Key::derive_from(&COOKIE_KEY_MASTER))
.add(Cookie::new(COOKIE_NAME, identity)); .add(Cookie::new(COOKIE_NAME, identity));
jar.get(COOKIE_NAME).unwrap().clone() jar.get(COOKIE_NAME).unwrap().clone()
} }
@ -774,7 +774,7 @@ mod tests {
let mut jar = CookieJar::new(); let mut jar = CookieJar::new();
let key: Vec<u8> = let key: Vec<u8> =
COOKIE_KEY_MASTER.iter().chain([1, 0, 0, 0].iter()).map(|e| *e).collect(); COOKIE_KEY_MASTER.iter().chain([1, 0, 0, 0].iter()).map(|e| *e).collect();
jar.private(&Key::derive_from(&key)).add(Cookie::new( jar.private_mut(&Key::derive_from(&key)).add(Cookie::new(
COOKIE_NAME, COOKIE_NAME,
serde_json::to_string(&CookieValue { serde_json::to_string(&CookieValue {
identity: identity.to_string(), identity: identity.to_string(),

View file

@ -16,7 +16,7 @@ name = "ntex_multipart"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
ntex = "0.3.2" ntex = "0.3.5"
derive_more = "0.99.11" derive_more = "0.99.11"
httparse = "1.3" httparse = "1.3"
futures = "0.3.13" futures = "0.3.13"

View file

@ -22,8 +22,8 @@ default = ["cookie-session"]
cookie-session = ["cookie/secure", "ntex/cookie"] cookie-session = ["cookie/secure", "ntex/cookie"]
[dependencies] [dependencies]
ntex = "0.3.2" ntex = "0.3.5"
cookie = "0.14.2" cookie = "0.15"
derive_more = "0.99.11" derive_more = "0.99.11"
futures = "0.3.13" futures = "0.3.13"
serde = "1.0" serde = "1.0"

View file

@ -118,8 +118,8 @@ impl<Err> CookieSessionInner<Err> {
let mut jar = CookieJar::new(); let mut jar = CookieJar::new();
match self.security { match self.security {
CookieSecurity::Signed => jar.signed(&self.key).add(cookie), CookieSecurity::Signed => jar.signed_mut(&self.key).add(cookie),
CookieSecurity::Private => jar.private(&self.key).add(cookie), CookieSecurity::Private => jar.private_mut(&self.key).add(cookie),
} }
for cookie in jar.delta() { for cookie in jar.delta() {
@ -506,6 +506,9 @@ mod tests {
.expires() .expires()
.expect("Expiration is set"); .expect("Expiration is set");
assert!(expires_2 - expires_1 >= Duration::seconds(1)); assert!(
expires_2.datetime().unwrap() - expires_1.datetime().unwrap()
>= Duration::seconds(1)
);
} }
} }