Skip to content

Commit c982a71

Browse files
committed
Auto merge of #2500 - jtgeibel:update/cookie-and-time, r=JohnTitor
Bump to the latest `cookie` crate These upstream `conduit-*` crates now pull in the latest versions of `cookie` and `time`. In particular, the following changes to cookie behavior are made: * `cookie` is bumped to 0.13 * `Max-Age` is set to 90 days * `Same-Site=Strict` is added to the session cookie * Only set the session cookie in the response if the session was modified r? @JohnTitor
2 parents 338868e + faa2cad commit c982a71

File tree

3 files changed

+162
-31
lines changed

3 files changed

+162
-31
lines changed

Cargo.lock

Lines changed: 154 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ lettre_email = "0.9"
6767
failure = "0.1.1"
6868

6969
conduit = "0.9.0-alpha.2"
70-
conduit-conditional-get = "0.9.0-alpha.2"
71-
conduit-cookie = "0.9.0-alpha.2"
72-
cookie = { version = "0.12", features = ["secure"] }
70+
conduit-conditional-get = "0.9.0-alpha.3"
71+
conduit-cookie = "0.9.0-alpha.3"
72+
cookie = { version = "0.13", features = ["secure"] }
7373
conduit-middleware = "0.9.0-alpha.2"
7474
conduit-router = "0.9.0-alpha.2"
75-
conduit-static = "0.9.0-alpha.2"
75+
conduit-static = "0.9.0-alpha.3"
7676
conduit-git-http-backend = "0.9.0-alpha.2"
7777
civet = "0.12.0-alpha.3"
7878
conduit-hyper = "0.3.0-alpha.2"

src/controllers/user/session.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn begin(req: &mut dyn RequestExt) -> EndpointResult {
3131
.github
3232
.authorize_url(oauth2::CsrfToken::new_random);
3333
let state = state.secret().to_string();
34-
req.session()
34+
req.session_mut()
3535
.insert("github_oauth_state".to_string(), state.clone());
3636

3737
#[derive(Serialize)]
@@ -82,7 +82,7 @@ pub fn authorize(req: &mut dyn RequestExt) -> EndpointResult {
8282
// Make sure that the state we just got matches the session state that we
8383
// should have issued earlier.
8484
{
85-
let session_state = req.session().remove(&"github_oauth_state".to_string());
85+
let session_state = req.session_mut().remove(&"github_oauth_state".to_string());
8686
let session_state = session_state.as_deref();
8787
if Some(&state[..]) != session_state {
8888
return Err(bad_request("invalid state parameter"));
@@ -104,7 +104,7 @@ pub fn authorize(req: &mut dyn RequestExt) -> EndpointResult {
104104
let user = ghuser.save_to_database(&token.secret(), &*req.db_conn()?)?;
105105

106106
// Log in by setting a cookie and the middleware authentication
107-
req.session()
107+
req.session_mut()
108108
.insert("user_id".to_string(), user.id.to_string());
109109
req.mut_extensions().insert(TrustedUserId(user.id));
110110

@@ -149,7 +149,7 @@ impl GithubUser {
149149

150150
/// Handles the `DELETE /api/private/session` route.
151151
pub fn logout(req: &mut dyn RequestExt) -> EndpointResult {
152-
req.session().remove(&"user_id".to_string());
152+
req.session_mut().remove(&"user_id".to_string());
153153
Ok(req.json(&true))
154154
}
155155

0 commit comments

Comments
 (0)