Hi
I know business logic in JSPs is bad, but I need to come up with a solution quickly with how the codebase was setup. Anyways, I wanted to execute code only on a certain template so I'm using
currentPage.getTemplate().getTitle().equals("SomeTemplate")
I could provide code context but I think its more of permissions issue than a code issue. It only works when I log in, and if I'm not logged in it breaks. What permission do I need to edit to fix this.
Solved! Go to Solution.
Feike Visser wrote...
This is a much easier way, without changing permissions:
page.getProperties().get("cq:template","")
best,
Feike
Found this response in a different thread. Much better solution, and doesn't involve editing permissions.
Feike Visser wrote...
This is a much easier way, without changing permissions:
page.getProperties().get("cq:template","")
best,
Feike
Found this response in a different thread. Much better solution, and doesn't involve editing permissions.
I know business logic in JSPs is bad
That is not necessarily the case - AEM gives you choice to use HTML Template Language or JSP. It does not force you to use HTL.
Views
Replies
Total Likes
Basically: avoid using getTemplate()
Views
Replies
Total Likes
Hi guys, I realise this is an old post but I have encountered the same problem and I need a steer. Of course, the replacement of getTemplate() is the best solution but we have a site with an older code base that uses it extensively.
We have just implemented a user log-in system via Okta (which works well with SAML) but the Okta authenticated user immediately encounters problems with pages using any derivation of the getTemplate method.
Interestingly, our anonymous user does not have this issue. The Okta user is also added to the "everyone" group, just like the anonymous user.
What permissions would I need to add to the Okta user for them to access to this getTemplate() method?
Views
Replies
Total Likes
If they are added to everyone , I assume , they have all the permissions available for anonymous user. Not sure what might be going wrong. Its been ages I have used getTemplate last time.
Views
Replies
Total Likes
you need to have read access to /apps, potentially read access to /libs as well.
OK, thank you so much for your reply! Is that "safe" do you think?
Views
Replies
Total Likes
No :-)
The lock down of /apps (anonymous is not allowed to read from there) in the product has been done for a reason.
OK! Thanks again for your continued support.
As a test, I have added the Okta user to read /apps on a non-production environment and it does the trick. But, from what you say, this is not a situation that should exist on Live.
What is the practical technical impact of the anonymous user have read access to apps?
Views
Replies
Total Likes
In practice I don't think that it has a huge impact (disclaimer: I am not a security guy, they will possibly see this much different). But it's always good to adhere to the guidelines of the product.
Views
Likes
Replies