From 3b8b1d0d5321c80aa006f1874044687401da01cd Mon Sep 17 00:00:00 2001 From: Ralf Ramsauer Date: Mon, 18 May 2015 22:22:32 +0200 Subject: [PATCH] Removed authenticated feature. Authentication is now required --- doorlockd/logic.cpp | 46 +++++++++++++-------------------------------- doorlockd/logic.h | 2 -- 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/doorlockd/logic.cpp b/doorlockd/logic.cpp index 2463516..82a2de5 100644 --- a/doorlockd/logic.cpp +++ b/doorlockd/logic.cpp @@ -61,7 +61,6 @@ Logic::Response Logic::parseRequest(const string &str) Json::Value root; Response retval = Fail; string action, user, password, ip, token; - bool authenticate; bool suc = reader.parse(str, root, false); if (!suc) @@ -74,13 +73,9 @@ Logic::Response Logic::parseRequest(const string &str) try { action = getJsonOrFail(root, "action"); ip = getJsonOrFail(root, "ip"); - authenticate = getJsonOrFail(root, "authenticate"); - if (authenticate == true) - { - user = getJsonOrFail(root, "user"); - password = getJsonOrFail(root, "password"); - token = getJsonOrFail(root, "token"); - } + user = getJsonOrFail(root, "user"); + password = getJsonOrFail(root, "password"); + token = getJsonOrFail(root, "token"); } catch (...) { @@ -94,28 +89,18 @@ Logic::Response Logic::parseRequest(const string &str) _logger(" IP : " + ip, LogLevel::notice); _logger(" Token : " + token, LogLevel::notice); - if (authenticate == true) + if (_checkToken(token) == false) { - if (_checkToken(token) == false) - { - _logger(LogLevel::error, "User provided invalid token"); - retval = InvalidToken; - goto out; - } + _logger(LogLevel::error, "User provided invalid token"); + retval = InvalidToken; + goto out; + } - retval = _checkLDAP(user,password); - if (retval != Success) - { - _logger(LogLevel::error, "Ldap error"); - goto out; - } - } else { - if (_checkIP(ip) == false) - { - _logger(LogLevel::error, "IP check for non-authentication failed"); - retval = InvalidIP; - goto out; - } + retval = _checkLDAP(user,password); + if (retval != Success) + { + _logger(LogLevel::error, "Ldap error"); + goto out; } if (action == "lock") @@ -163,11 +148,6 @@ Logic::Response Logic::_unlock() return Success; } -bool Logic::_checkIP(const string &ip) -{ - return true; -} - bool Logic::_checkToken(const string &strToken) { try { diff --git a/doorlockd/logic.h b/doorlockd/logic.h index 7ed7149..9a84f82 100644 --- a/doorlockd/logic.h +++ b/doorlockd/logic.h @@ -47,8 +47,6 @@ private: bool _checkToken(const std::string &token); Response _checkLDAP(const std::string &user, const std::string &password); - bool _checkIP(const std::string &ip); - void _createNewToken(const bool stillValid); const Logger &_logger;