Expand my Community achievements bar.

Issues with accessing /apps path

Avatar

Level 3

Hello Community - We have some issues with accessing /apps path for the anonymous user. We have few components in our project in those component, we are using multiple references of /apps paths in it(i.e. See below). If we access the page as a logged in user, we are able to see the component but if we access the same page as an anonymous user using the publish url, we don't see the component.

 

Since the /apps path read access is restricted for anonymous user so we don't see the component loading on the page. If we grant read access to everyone group, we started seeing the component. I know we shouldn't grant any read permissions to /apps path due to security aspects, it is related to clientlibs, we can specify allowProxy so that we can access it using /etc.clientlibs but in this case it's not clientlibs, so can someone tell me how to address this scenario. also please note that creating service user and grant read access is not an option for this usecase.

<sly data-sly-use.test="/apps/project/components/content/.../test.html"/>

7 Replies

Avatar

Level 7

Hi @test1234567 

 

If you want to refer other component, then try below statement.

 

<sly data-sly-resource="${'image' @ resourceType='weretail/components/content/image'}"></sly>

<div data-sly-resource="${'/content/abc/us/en/author'}"></div>

Avatar

Level 3

We already using the reference like below in the html, should we need to remove the /apps/ reference the below? We have to use data-sly-use only as we need this object to use it.

<sly data-sly-use.clientlib="/apps/project/components/content/sightly/templates/clientlib.html"  />

Avatar

Level 7

Hi @test1234567 

 

I am not getting your intention.

 

Do not want to include clientlib? if yes, use this code

<sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html"
data-sly-call="${clientlib.all @ categories=['abc.testName']}" />

Or, if your task is different, could you please explain?

Note: If you want to include other file content, then try this one:

<div data-sly-resource="${'/content/abc/us/en/author'}"></div>

Avatar

Level 7

Hi @test1234567 

 

Try this way.


<sly data-sly-use.clientlib="project/components/content/sightly/templates/clientlib.html"
data-sly-call="${clientlib.all @ categories=['abc.testName']}" />

Will it work ???? Fingers crossed

Avatar

Level 3

The issue is not with the clientlib loading. Here is the scenario. Let's consider we have two different paths.

 

Path1: /apps/project1/components/content/global/global.html

Path2: /apps/project2/components/content/module/module.html

 

If I use the path2 in the path1 html (global.html), it is loading in publish only if I grant read access to /apps/ path if I don't grant access to /apps/ then it is not working for anonymous users accessing the page. Also it is not advisable to grant read access to /apps/ path. In these scenarios, are there any way to handle this scenario without creating any service user to grant access. Also consider there is no backend sling model used for this component.

 

<sly data-sly-use.test="/apps/project2/components/content/module/module.html"/>

 

Avatar

Level 7

Hi @test1234567 

 

Can you try this code snippet?

Created a component in we-retail project
/apps/weretail/components/content/maddy
 
maddy.html has sentence:  Hello World
 
 
My component
/apps/practice/components/dynamicComponent
 
dynamicComponent.html has this content.
 

 

 

<div data-sly-resource="${ 'sample' @ resourceType='weretail/components/content/maddy', appendPath='/*', decorationTagName='div',
cssClassName='cmp-helloworld__item'}"
data-sly-test="${(wcmmode.edit || wcmmode.preview || wcmmode.disabled) }"></div>
 
This worked in my local publish environment for anonymous user

Avatar

Level 7

Hi @test1234567 

Sometimes, because of the div class or the style, text may not be visible. In this case, try to put some alert or console statement in your  /apps/project2/components/content/module/module.html file