How can I restrict the content using query builder to a particular user for a given node | Community
Skip to main content
New Participant
October 16, 2015
Solved

How can I restrict the content using query builder to a particular user for a given node

  • October 16, 2015
  • 3 replies
  • 1409 views

In geometrix site if I need to get the results for page which has only user X has access 

Following query pulls all the records but I need to restrict to user X who can access contents at /content/geometrixx

http://localhost:4502/bin/querybuilder.feed?orderby=%40jcr%3acontent%2fjcr%3acreated&orderby.index=true&orderby.sort=desc&path=%2fcontent%2fgeometrixx%2fen&type=cq%3aPage

What are the parameters that need to be included in the url

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 smacdonald2008

When you use the QUeryBuilder Java API from within an OSGi bundle - you have much finer control than the Rest API. For example --  you can control when the call is made and under what circumstances by developing correct application logic. You can see who the user is and if its not the user that you want - then do not let the call proceed. In other words - write application logic to control this. 

 

Information about the Query Builder Restful API is here:

http://dev.day.com/docs/en/cq/current/dam/customizing_and_extendingcq5dam/query_builder.html

There are different examples -- including using Groups. 

3 replies

smacdonald2008
smacdonald2008Accepted solution
New Participant
October 16, 2015

When you use the QUeryBuilder Java API from within an OSGi bundle - you have much finer control than the Rest API. For example --  you can control when the call is made and under what circumstances by developing correct application logic. You can see who the user is and if its not the user that you want - then do not let the call proceed. In other words - write application logic to control this. 

 

Information about the Query Builder Restful API is here:

http://dev.day.com/docs/en/cq/current/dam/customizing_and_extendingcq5dam/query_builder.html

There are different examples -- including using Groups. 

joerghoh
Employee
October 16, 2015

By default the query builder servlet uses the session, which has been created with the permissions of the logged in user. So if you want to get results only a user X can see, you should send proper authentication for the user X for this request to the querybuilder, and that's it.

If you don't want to do this, you need to write your own servlet (or a wrapper around the querybuilder servlet), which accepts the username as a parameter, opens a session for this user and then does the query in the scope of this session.

Jörg

Sham_HC
New Participant
October 16, 2015

Agree with scott.  If you have dispatcher use mod_security example at http://helpx.adobe.com/experience-manager/kb/restrict-system-administrator-login-specific.html

Additionally you can use filter an sample example of different use case at http://aemfaq.blogspot.com/2013/05/blocking-anonymous-access-to-crx-in-non.html