mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-30 22:50:10 +03:00
feature #203: Authenticate now uses the Auth Manager infrastructure
This commit is contained in:
parent
2cc7ff67be
commit
284a2db716
@ -50,7 +50,6 @@ public:
|
||||
*/
|
||||
string& to_xml(string& xml) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get the User unique identifier UID, that matches the OID of the object
|
||||
* @return UID User identifier
|
||||
@ -119,12 +118,6 @@ public:
|
||||
password = _password;
|
||||
};
|
||||
|
||||
/**
|
||||
* Looks for a match between _password and user password
|
||||
* @return -1 if disabled or wrong password, uid otherwise
|
||||
**/
|
||||
int authenticate(string _password);
|
||||
|
||||
/**
|
||||
* Splits an authentication token (<usr>:<pass>)
|
||||
* @param secret, the authentication token
|
||||
|
@ -40,6 +40,7 @@ env.Append(LIBS=[
|
||||
'nebula_dm',
|
||||
'nebula_tm',
|
||||
'nebula_um',
|
||||
'nebula_authm',
|
||||
'nebula_mad',
|
||||
'nebula_template',
|
||||
'nebula_image',
|
||||
|
@ -307,21 +307,6 @@ string& User::to_str(string& str) const
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int User::authenticate(string _password)
|
||||
{
|
||||
if (enabled && _password==password)
|
||||
{
|
||||
return oid;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int User::split_secret(const string secret, string& user, string& pass)
|
||||
{
|
||||
size_t pos;
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "UserPool.h"
|
||||
#include "NebulaLog.h"
|
||||
#include "AuthManager.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <sys/types.h>
|
||||
@ -178,8 +180,42 @@ int UserPool::authenticate(string& session)
|
||||
|
||||
if ( index != known_users.end() )
|
||||
{
|
||||
User * user = get((int)index->second,false);
|
||||
user_id = user->authenticate(password);
|
||||
User * user = get((int)index->second,true);
|
||||
|
||||
if ( user != 0 )
|
||||
{
|
||||
AuthRequest ar(user->get_uid());
|
||||
|
||||
Nebula& nd = Nebula::instance();
|
||||
AuthManager * authm = nd.get_authm();
|
||||
|
||||
ar.add_authenticate(user->username,
|
||||
user->password,
|
||||
password);
|
||||
if ( authm == 0 && ar.plain_authenticate() )
|
||||
{
|
||||
user_id = user->get_uid();
|
||||
}
|
||||
else
|
||||
{
|
||||
authm->trigger(AuthManager::AUTHENTICATE,&ar);
|
||||
ar.wait();
|
||||
|
||||
if (ar.result==true)
|
||||
{
|
||||
user_id = user->get_uid();
|
||||
}
|
||||
else
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << "Auth Error: " << ar.message;
|
||||
|
||||
NebulaLog::log("AuM",Log::ERROR,oss);
|
||||
}
|
||||
}
|
||||
|
||||
user->unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user