Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to enable access to "/bin/querybuilder.json" to any user ?

Avatar

Level 7
 
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @akshaybhujbale Sling Engine will take care of permissions if you register servlet using Resource Type.

Users who cannot access a particular resource will not be able to invoke the servlet.

Path-bound servlets cannot be access controlled using the default JCR repository ACLs.

Reference - https://sling.apache.org/documentation/the-sling-engine/servlets.html#example-registration-by-resour...

 

@Component(service = Servlet.class)
@SlingServletResourceTypes(
        resourceTypes = "services/testServlet",
        methods = { HttpConstants.METHOD_GET }
)
@ServiceDescription("Test Servlet")
public class TestServlet extends SlingAllMethodsServlet {
     @Override
    protected void doGet(final SlingHttpServletRequest request, final 
SlingHttpServletResponse response)
            throws ServletException, IOException {
      // business-logic over here
}
}

Hope this helps!

Thanks

View solution in original post

2 Replies

Avatar

Level 6

@akshaybhujbale

I think /bin/querybuilder.json makes a request to servlet which is registered with a path /bin/querybuilder and an extenstion json. Servlets registered with path can not be access controlled so I think we can not provide its access to any user.

Avatar

Correct answer by
Community Advisor

Hi @akshaybhujbale Sling Engine will take care of permissions if you register servlet using Resource Type.

Users who cannot access a particular resource will not be able to invoke the servlet.

Path-bound servlets cannot be access controlled using the default JCR repository ACLs.

Reference - https://sling.apache.org/documentation/the-sling-engine/servlets.html#example-registration-by-resour...

 

@Component(service = Servlet.class)
@SlingServletResourceTypes(
        resourceTypes = "services/testServlet",
        methods = { HttpConstants.METHOD_GET }
)
@ServiceDescription("Test Servlet")
public class TestServlet extends SlingAllMethodsServlet {
     @Override
    protected void doGet(final SlingHttpServletRequest request, final 
SlingHttpServletResponse response)
            throws ServletException, IOException {
      // business-logic over here
}
}

Hope this helps!

Thanks