Skip to content

Commit

Permalink
Move the session key to an env var
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Jul 15, 2014
1 parent a7e9cf2 commit 191ceda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct App {
db: PostgresConnectionPool,
pub github: oauth2::Config,
pub bucket: s3::Bucket,
pub session_key: String,
}

pub struct AppMiddleware {
Expand All @@ -39,6 +40,7 @@ impl App {
bucket: s3::Bucket::new(env("S3_BUCKET"),
env("S3_ACCESS_KEY"),
env("S3_SECRET_KEY")),
session_key: env("SESSION_KEY"),
};

fn env(s: &str) -> String {
Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ fn main() {
m.add(conduit_json_parser::BodyReader::<package::UpdateRequest>);
router.put("/packages/:package_id", m);

let app = App::new();

let mut m = MiddlewareBuilder::new(router);
m.add(conduit_log_requests::LogRequests(0));
m.add(conduit_conditional_get::ConditionalGet);
m.add(conduit_cookie::Middleware::new(b"application-key"));
m.add(conduit_cookie::Middleware::new(app.session_key.as_bytes()));
m.add(conduit_cookie::SessionMiddleware::new("cargo_session"));
m.add(app::AppMiddleware::new(App::new()));
m.add(app::AppMiddleware::new(app));
m.add(user::Middleware);

let port = 8888;
Expand Down

0 comments on commit 191ceda

Please sign in to comment.