mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-16 17:53:08 +09:00
feature #203: Plain authorize method fix
This commit is contained in:
1 parent
e3c5c8086c
commit
2fe5b7b740
1 file changed
+43
-9
@@ -76,7 +76,7 @@ void AuthRequest::add_auth(Object ob,
|
||||
bool pub)
|
||||
{
|
||||
ostringstream oss;
|
||||
bool auth = owner == uid;
|
||||
bool auth;
|
||||
|
||||
switch (ob)
|
||||
{
|
||||
@@ -118,14 +118,6 @@ void AuthRequest::add_auth(Object ob,
|
||||
|
||||
case USE:
|
||||
oss << "USE:" ;
|
||||
if ( ob == NET || ob == IMAGE )
|
||||
{
|
||||
auth = auth || (pub == true);
|
||||
}
|
||||
else if (ob == HOST)
|
||||
{
|
||||
auth = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case MANAGE:
|
||||
@@ -135,6 +127,48 @@ void AuthRequest::add_auth(Object ob,
|
||||
|
||||
oss << owner << ":" << pub;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Authorize the request for self authorization
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
if ( uid == 0 )
|
||||
{
|
||||
auth = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
auth = false;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case CREATE:
|
||||
if ( ob == VM || ob == NET || ob == IMAGE )
|
||||
{
|
||||
auth = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case DELETE:
|
||||
auth = owner == uid;
|
||||
break;
|
||||
|
||||
case USE:
|
||||
if (ob == NET || ob == IMAGE)
|
||||
{
|
||||
auth = (owner == uid) || pub
|
||||
}
|
||||
else if (ob == HOST)
|
||||
{
|
||||
auth = true
|
||||
}
|
||||
break;
|
||||
|
||||
case MANAGE:
|
||||
auth = owner == uid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self_authorize = self_authorize && auth;
|
||||
|
||||
auths.push_back(oss.str());
|
||||
|
||||
Reference in new issue
Block a user