Abhishek created RANGER-3884:
--------------------------------

             Summary: POST request to /service/xusers/permission/user API 
results in ERROR_DUPLICATE_OBJECT error
                 Key: RANGER-3884
                 URL: https://issues.apache.org/jira/browse/RANGER-3884
             Project: Ranger
          Issue Type: Bug
          Components: Ranger
            Reporter: Abhishek


When a POST request is made to the url 
\{RANGER_ADMIN_URL}//service/xusers/permission/user to assign permission on a 
module to a user for the first time, the API works as expected and the 
permission is 
assigned to the user on the module.
But when the permission on the module is removed for the user from the UI,
and a POST request is made again to assign permission on the same module for 
the same user, it results in the following error
{code:java|bgColor=#f4f5f7}
{    "statusCode": 1,    "msgDesc": "User with ID [76] is already assigned to 
the module with ID [4]",    "messageList": [        {            "name": 
"ERROR_DUPLICATE_OBJECT",            "rbKey": "xa.error.duplicate_object",      
      "message": "Error creating duplicate object"        }    ]} {code}
*Steps to reproduce:-*
1. Create a new user in Ranger Admin 
2. Make the following POST request using the newly created user's user id and 
username with the following payload
{code:java|bgColor=#f4f5f7}
{  "userId" : new_user_user_id,  "moduleId" : 4,  "isAllowed" : 1,  "userName" 
: new_user_username,  "moduleName" : "Audits",  "loginId" : new_user_username} 
{code}
3. The user will be granted permissions on the Audits module
4. Go to the UI, remove the permissions for the user on the Audits module
5. Then make a POST request to the same REST endpoint with the same payload.
Since the user did not have permissions on the Audits module, the user should 
have 
been granted access on the Audits module, but it results in the following error
{code:java|bgColor=#f4f5f7}
{    "statusCode": 1,    "msgDesc": "User with ID [127] is already assigned to 
the module with ID [4]",    "messageList": [        {            "name": 
"ERROR_DUPLICATE_OBJECT",            "rbKey": "xa.error.duplicate_object",      
      "message": "Error creating duplicate object"        }    ]} {code}
Also, the user id in the error message is always user_id_in_payload - 2.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to