cancel
Showing results for 
Search instead for 
Did you mean: 

Search in WebScript with guest authentication

andrepra
Champ in-the-making
Champ in-the-making
Hi,
I wrote a very simple web script in alfresco 3.0. The controller simply get a parameter from the request and set the space variable
var imageSpace = search.findNode("workspace://SpacesStore/" + args["uuid"]);model.space = imageSpace;‍‍‍‍

and the ftl template show the images contained in the space.
Setting the authentication as user everything works fine. Setting the authentication as none I get this exception
net.sf.acegisecurity.AuthenticationCredentialsNotFoundException - A valid SecureContext was not provided in the RequestContextnet.sf.acegisecurity.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:477)….org.alfresco.error.AlfrescoRuntimeException - Failed to execute search: ID:workspace\://SpacesStore/29b2aa8f\-bd8a\-4bf6\-93eb\-2d75dd3c12dd    org.alfresco.repo.jscript.Search.query(Search.java:451)‍‍‍‍‍‍‍‍‍‍
The space is the guest home so the permissions are ok. Seems that there's some problem executing the search without the secure context. Looking the source of the RepositoryContainer class I saw that call to clearCurrentSecurityContext()
if (required == RequiredAuthentication.none)        {            // MT-context will pre-authenticate (see MTWebScriptAuthenticationFilter)            if (! AuthenticationUtil.isMtEnabled())            {                // TODO revisit - cleared here, in-lieu of WebClient clear                AuthenticationUtil.clearCurrentSecurityContext();            }            transactionedExecuteAs(script, scriptReq, scriptRes);        }‍‍‍‍‍‍‍‍‍‍‍‍
My question is: is this an error or I have to use another API to perform the search.
Thanks
Andrea
2 REPLIES 2

mikeh
Star Contributor
Star Contributor
Setting authentication to "none" is very different to "guest", which is what I believe you need.

Mike

andrepra
Champ in-the-making
Champ in-the-making
Thanks! Works fine! Seems that refreshing the scripts while Alfresco is running update the ftl and js but not the desc.xml.

Thanks again
Andrea