Anupam Rai created RANGER-4031:
----------------------------------

             Summary: [Ranger Admin] Not able to fetch Policy details using 
guid /api/policy/guid/{guid} without service name
                 Key: RANGER-4031
                 URL: https://issues.apache.org/jira/browse/RANGER-4031
             Project: Ranger
          Issue Type: Bug
          Components: Ranger
            Reporter: Anupam Rai


Not able to fetch Policy details using guid /api/policy/guid/\{guid} without 
service name

Request without servicename 
{code:java}
curl -s -L -X GET 
"https://q************/service/public/v2/api/policy/guid/****-2f42-4451-9edf-****";
 -H "Content-Type: application/json" -H "Accept: application/json" -H 
"Authorization: Basic *********DEyMw=="{code}
Response : 404 

Request with servicename 
{code:java}
curl -s -L -X GET 
"https://****************/service/public/v2/api/policy/guid/*****-2f42-4451-9edf-****?serviceName=hive";
 -H "Content-Type: application/json" -H "Accept: application/json" -H 
"Authorization: Basic ***************=="{code}
Response Proper : 200 with proper details 

Code : 
[https://github.com/apache/ranger/blob/master/security-admin/src/main/java/org/apache/ranger/rest/PublicAPIsv2.java#L505]
{code:java}
@GET    @Path("/api/policy/guid/{guid}")        
@Produces({ "application/json", "application/xml" })
public RangerPolicy getPolicyByGUIDAndServiceNameAndZoneName(@PathParam("guid") 
String guid,                                                                    
                                                         @DefaultValue("") 
@QueryParam("serviceName") String serviceName,                                  
                                                                                
              @DefaultValue("") @QueryParam("ZoneName") String zoneName) {
                return 
serviceREST.getPolicyByGUIDAndServiceNameAndZoneName(guid, serviceName, 
zoneName);       } {code}
As query parameters are optional it should give proper response 

Expected : User should be able to get policy details using only guid in path 
params 

Thanks 



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

Reply via email to