Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Updating WS + Increasing token validity #1882

Merged
merged 3 commits into from
Aug 9, 2016
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
100 changes: 72 additions & 28 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ rand = "0.3.14"
jsonrpc-core = "2.1"
log = "0.3"
env_logger = "0.3"
ws = { git = "https://github.com/ethcore/ws-rs.git", branch = "stable" }
ws = { git = "https://github.com/ethcore/ws-rs.git", branch = "mio-upstream-stable" }
ethcore-util = { path = "../util" }
ethcore-io = { path = "../util/io" }
ethcore-rpc = { path = "../rpc" }
Expand Down
8 changes: 4 additions & 4 deletions signer/src/authcode_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl TimeProvider for DefaultTimeProvider {
}

/// No of seconds the hash is valid
const TIME_THRESHOLD: u64 = 2;
const TIME_THRESHOLD: u64 = 7;
const TOKEN_LENGTH: usize = 16;

/// Manages authorization codes for `SignerUIs`
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<T: TimeProvider> AuthCodes<T> {
let now = self.now.now();
// check time
if time >= now + TIME_THRESHOLD || time <= now - TIME_THRESHOLD {
warn!(target: "signer", "Received old authentication request.");
warn!(target: "signer", "Received old authentication request. ({} vs {})", now, time);
return false;
}

Expand Down Expand Up @@ -169,8 +169,8 @@ mod tests {
fn should_return_false_if_hash_is_valid_but_time_is_invalid() {
// given
let code = "23521352asdfasdfadf";
let time = 105;
let time2 = 95;
let time = 107;
let time2 = 93;
let codes = AuthCodes::new(vec![code.into()], || 100);

// when
Expand Down
4 changes: 3 additions & 1 deletion signer/src/ws_server/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ impl ws::Handler for Session {
fn on_message(&mut self, msg: ws::Message) -> ws::Result<()> {
let req = try!(msg.as_text());
match self.handler.handle_request(req) {
Some(res) => self.out.send(res),
Some(res) => {
self.out.send(res)
},
None => Ok(()),
}
}
Expand Down