1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 02:14:26 +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 52fa880e61
commit 3b8b1d0d53
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;
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<string>(root, "action");
ip = getJsonOrFail<string>(root, "ip");
authenticate = getJsonOrFail<bool>(root, "authenticate");
if (authenticate == true)
{
user = getJsonOrFail<string>(root, "user");
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 (...)
{
@ -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 {

View File

@ -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;