Skip to content

Bump to the latest cookie crate #2500

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

Merged
merged 2 commits into from
May 11, 2020
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
177 changes: 154 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ lettre_email = "0.9"
failure = "0.1.1"

conduit = "0.9.0-alpha.2"
conduit-conditional-get = "0.9.0-alpha.2"
conduit-cookie = "0.9.0-alpha.2"
cookie = { version = "0.12", features = ["secure"] }
conduit-conditional-get = "0.9.0-alpha.3"
conduit-cookie = "0.9.0-alpha.3"
cookie = { version = "0.13", features = ["secure"] }
conduit-middleware = "0.9.0-alpha.2"
conduit-router = "0.9.0-alpha.2"
conduit-static = "0.9.0-alpha.2"
conduit-static = "0.9.0-alpha.3"
conduit-git-http-backend = "0.9.0-alpha.2"
civet = "0.12.0-alpha.3"
conduit-hyper = "0.3.0-alpha.2"
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/user/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn begin(req: &mut dyn RequestExt) -> EndpointResult {
.github
.authorize_url(oauth2::CsrfToken::new_random);
let state = state.secret().to_string();
req.session()
req.session_mut()
.insert("github_oauth_state".to_string(), state.clone());

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

// Log in by setting a cookie and the middleware authentication
req.session()
req.session_mut()
.insert("user_id".to_string(), user.id.to_string());
req.mut_extensions().insert(TrustedUserId(user.id));

Expand Down Expand Up @@ -149,7 +149,7 @@ impl GithubUser {

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

Expand Down