RE: Display knowledge base artilce in asset pulpisher in lifeay 7.1 to Gue

thumbnail
Nader Jafari, modified 6 Years ago. Junior Member Posts: 84 Join Date: 8/24/11 Recent Posts
Hi guys

i added some articles in knowledege base portlet and now i want to display these in asset pulisher portlet.
when i configure an asset pulisher portlet all URLs start with /c/knowledge_base/find_kb_article and when i click on these links liferay shows me login portlet that seem need to login to display contents of article.
all articles have Guest permission and display fine in Knowledege Base Display portlet to guests.

Could someone help me please?
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Nader, 

I'm not sure if this will make a difference since you said you set each of the articles to have the VIEW permission for the Guest role -- but can you try

1. Log in as admin
2. Control Panel > Users > Roles
3. Guest Row > Stop Light Menu or Kebab > Edit
4. Across the top is a link for "Define Permissions"
5. Expand Site Administration (left tree)
6. Expand Content
7. Click on Knowledge base

.. and make sure the correct permissions are in place. Note though that this will now become the default so it means that all KB articles will be visible to Guest users. Just mentioning it in case that is NOT what you want.

Also, just to make sure -- the Asset Publisher is configured to show the Knowledge Base asset type right? emoticon
thumbnail
Nader Jafari, modified 6 Years ago. Junior Member Posts: 84 Join Date: 8/24/11 Recent Posts
Hi Andrew
I checked all these as you said
  • All folders in KB portlet have the View permission for Guest role.
  • Asset Publisher posrtlet shows all KB articles as list fine.
  • Also KB Dislpay portlet shows all articles fine.
But all links in asset publisher as i said need to login emoticon
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Is the page that is being linked to a public page?
thumbnail
Nader Jafari, modified 6 Years ago. Junior Member Posts: 84 Join Date: 8/24/11 Recent Posts
I placet an Asset publisher portlet in Home page that is public and guest can view this page fine.
Next , i confiured this portlet to display KB articles and Works fine.
I have another page in this site that i placed a KB Display Portlet on that and shows all articles fine.
Guest can views all articles in second page But when i click on listed articles in Asset publisher portlet that placed in Home page , Liferay redirect me to Login page!
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Ok -- I was just checking. I'll try to replicate your configuration on my side to see what I get for results.
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Nader, 

Alright I have reproduced your issue. I used the same setup that you specified above, however when I first did it, was working. But when I change the display type on teh asset publisher to "View in Context" it broke -- or rather it behaves the way you said, by challenging me to authenticate first. 

Looking at the URL though I can see that it uses 
http://localhost:8080/c/knowledge_base/find_kb_article?plid=20129&resourcePrimKey=105031&redirect=%2Fweb%2Fguest%2Fhome%3Fp_p_id%3Dcom_liferay_login_web_portlet_LoginPortlet%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_state_rcv%3D1
.. the leading /c indicates that it is a StrutsAction (service) that is being invoked. My guess is that it's challenging you for creds because that path is not listed as public. By default, struts actions services are private and if you want to make a path public, then you have to set the property auth.public.path to include the path you want to be unprotected. In Liferay with OSGI you can do this with a simple service. 
​​​​​​​@Component(
    immediate = true,
    property = {
        "auth.public.path=/knowledge_base/find_kb_article"
    },
    service = Object.class
)
public class KBPublicPath {
  // empty class -- used only to make teh knowledge base struts action path public
}

One thing to keep in mind though is that this will make this action public for all knowledge bases (on this site and others) because the struts action is a server level change. 

Let me know if that helps -- I didn't actuall try it on my side emoticon
thumbnail
Nader Jafari, modified 6 Years ago. Junior Member Posts: 84 Join Date: 8/24/11 Recent Posts
Thank you for detailed reply  emoticon it works!
But i do this by another way like liferay 6.1, i set this property in portal-ext.properties and append /knowledge_base/find_kb_article to this property value , is it wrong?
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Nader,

That's good to hear. No, it's not wrong -- you can do it that way as well of course. The only downside to that approach is that you lose some of the awesome dynamism that Liferay gives you. By putting it in a module it allows you to turn the public path "on and off" at runtime without the need to restart the server. In your case though, it's probably not an issue because that KB is an out of the box feature -- but if you ever find yourself defining your own public paths, I would encourage you to use the module approach so that the paths come and go with the availability of your feature.
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
I thought about it a little more and there is one more thing to consider when using the portal-ext. With each release, more and more of the portal-ext properties are deprecated as they are moved into new models... Usually the control panel somewhere. So it might work now, but might stop working in an upgrade.
thumbnail
Nader Jafari, modified 6 Years ago. Junior Member Posts: 84 Join Date: 8/24/11 Recent Posts
Thank you Andrew.
I am new in liferay 7 emoticon and OSGI is great!
i think if this path does not work for Guest so this is a bug!
everyone expect that works for Guest when KB articles have enough permissions!
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hahaha .. well that's an argument for you to have with Liferay emoticon. If you really believe it to be an error, then I suggest you open a ticket at issues.liferay.com and state your case there emoticon