mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #203: Adding authorization for Image allocate
This commit is contained in:
parent
0efe68bff1
commit
f7d3833c10
@ -15,10 +15,12 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#include "RequestManager.h"
|
||||
#include "NebulaLog.h"
|
||||
|
||||
#include "NebulaLog.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
#include "AuthManager.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -55,6 +57,19 @@ void RequestManager::ImageAllocate::execute(
|
||||
}
|
||||
|
||||
uid = rc;
|
||||
|
||||
//Authorize the operation
|
||||
if ( uid != 0 ) // uid == 0 means oneadmin
|
||||
{
|
||||
AuthRequest ar(uid);
|
||||
|
||||
ar.add_auth(AuthRequest::IMAGE,-1,AuthRequest::CREATE,0,false);
|
||||
|
||||
if (UserPool::authorize(ar) == -1)
|
||||
{
|
||||
goto error_authorize;
|
||||
}
|
||||
}
|
||||
|
||||
rc = ImageAllocate::ipool->allocate(uid,image_template,&iid);
|
||||
|
||||
@ -78,6 +93,10 @@ void RequestManager::ImageAllocate::execute(
|
||||
error_authenticate:
|
||||
oss << "User not authenticated, aborting ImageAllocate call.";
|
||||
goto error_common;
|
||||
|
||||
error_authorize:
|
||||
oss << "User not authorized to allocate a new IMAGE";
|
||||
goto error_common;
|
||||
|
||||
error_allocate:
|
||||
if (rc == -1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user