How to enable access to "/bin/querybuilder.json" to any user ? | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ShaileshBassi

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-resource-type-etc-1

 

@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

2 replies

Community Advisor
April 19, 2023

@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.

ShaileshBassi
Community Advisor
ShaileshBassiCommunity AdvisorAccepted solution
Community Advisor
April 19, 2023

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-resource-type-etc-1

 

@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