summaryrefslogtreecommitdiff
path: root/src/RpcMethod.cc
diff options
context:
space:
mode:
authorNils Maier <maierman@web.de>2014-04-19 19:10:06 +0200
committerNils Maier <maierman@web.de>2014-04-19 19:10:06 +0200
commit82dad90ff3fe1438ce5d578dcf50bc82e5c96e9b (patch)
treed3c0e83c55f04b84bddddca37d7c15b3daaea5f2 /src/RpcMethod.cc
parent98ba096951247b7e2119afe6ba4e4ddd7d4a4485 (diff)
Validate token using PBKDF2-HMAC-SHA1.
This change should make token validation more resilient to: - timing attacks (constant time array compare) - brute-force/dictionary attacks (PBKDF2) Closes #220
Diffstat (limited to 'src/RpcMethod.cc')
-rw-r--r--src/RpcMethod.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/RpcMethod.cc b/src/RpcMethod.cc
index e7b2750f..1f7ea20b 100644
--- a/src/RpcMethod.cc
+++ b/src/RpcMethod.cc
@@ -85,10 +85,8 @@ void RpcMethod::authorize(RpcRequest& req, DownloadEngine* e)
}
}
}
- if(e && e->getOption()->defined(PREF_RPC_SECRET)) {
- if(token != e->getOption()->get(PREF_RPC_SECRET)) {
- throw DL_ABORT_EX("Unauthorized");
- }
+ if (!e || !e->validateToken(token)) {
+ throw DL_ABORT_EX("Unauthorized");
}
}