1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 18:34:25 +01:00

Removed authenticated feature. Authentication is now required

This commit is contained in:
Ralf Ramsauer 2015-05-18 22:22:32 +02:00
parent c8dccd7bfc
commit f99ed93f29
2 changed files with 13 additions and 35 deletions

View File

@ -61,7 +61,6 @@ Logic::Response Logic::parseRequest(const string &str)
Json::Value root; Json::Value root;
Response retval = Fail; Response retval = Fail;
string action, user, password, ip, token; string action, user, password, ip, token;
bool authenticate;
bool suc = reader.parse(str, root, false); bool suc = reader.parse(str, root, false);
if (!suc) if (!suc)
@ -74,13 +73,9 @@ Logic::Response Logic::parseRequest(const string &str)
try { try {
action = getJsonOrFail<string>(root, "action"); action = getJsonOrFail<string>(root, "action");
ip = getJsonOrFail<string>(root, "ip"); ip = getJsonOrFail<string>(root, "ip");
authenticate = getJsonOrFail<bool>(root, "authenticate"); user = getJsonOrFail<string>(root, "user");
if (authenticate == true) password = getJsonOrFail<string>(root, "password");
{ token = getJsonOrFail<string>(root, "token");
user = getJsonOrFail<string>(root, "user");
password = getJsonOrFail<string>(root, "password");
token = getJsonOrFail<string>(root, "token");
}
} }
catch (...) catch (...)
{ {
@ -94,28 +89,18 @@ Logic::Response Logic::parseRequest(const string &str)
_logger(" IP : " + ip, LogLevel::notice); _logger(" IP : " + ip, LogLevel::notice);
_logger(" Token : " + token, 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;
_logger(LogLevel::error, "User provided invalid token"); goto out;
retval = InvalidToken; }
goto out;
}
retval = _checkLDAP(user,password); retval = _checkLDAP(user,password);
if (retval != Success) if (retval != Success)
{ {
_logger(LogLevel::error, "Ldap error"); _logger(LogLevel::error, "Ldap error");
goto out; goto out;
}
} else {
if (_checkIP(ip) == false)
{
_logger(LogLevel::error, "IP check for non-authentication failed");
retval = InvalidIP;
goto out;
}
} }
if (action == "lock") if (action == "lock")
@ -163,11 +148,6 @@ Logic::Response Logic::_unlock()
return Success; return Success;
} }
bool Logic::_checkIP(const string &ip)
{
return true;
}
bool Logic::_checkToken(const string &strToken) bool Logic::_checkToken(const string &strToken)
{ {
try { try {

View File

@ -47,8 +47,6 @@ private:
bool _checkToken(const std::string &token); bool _checkToken(const std::string &token);
Response _checkLDAP(const std::string &user, Response _checkLDAP(const std::string &user,
const std::string &password); const std::string &password);
bool _checkIP(const std::string &ip);
void _createNewToken(const bool stillValid); void _createNewToken(const bool stillValid);
const Logger &_logger; const Logger &_logger;