cancel
Showing results for 
Search instead for 
Did you mean: 

Dashlet calls autheniticated webscript

jelena
Champ in-the-making
Champ in-the-making
Hi,

1. I'm developing dashlet that calls web script which requires authentication. Thus I've tried to add alf_ticket at the end of webscript but the problem is I can't get the ticket from my:dashlet.get.js

I've tried with:

var ticket = session.getTicket();

and I get the error that session cant resolve session variable. So how can I get ticket from dashlet.get.js ?

2. And I was wondering is it possible to set document library of site to some alfresco folder?


Thanks very much for answers
7 REPLIES 7

mikeh
Star Contributor
Star Contributor
So how can I get ticket from dashlet.get.js ?
Use the /proxy servlet for authentication - see the existing dashlets for examples.

2. And I was wondering is it possible to set document library of site to some alfresco folder?
No, although you can set the Repository Browser to an arbitrary nodeRef (or xpath expression in HEAD, which will be 3.4.c)

Thanks,
Mike

croc
Champ in-the-making
Champ in-the-making
Hi,

I haven't tried it before but, can you try session.ticket;, maybe ti can work for you.

Thanx,
Croc

jelena
Champ in-the-making
Champ in-the-making
I've tried with shyre/proxy URL but it returns nothing.

My webscript is on this path: http://localhost:8080/alfresco/service/test/fetchP
and from my dashlet I'm trying to invoke it with http://localhost:29080/share/proxy/alfresco/test/fetchP (because share is on port 29080).

In share-config-custom.xml I defined port of Alfresco as is shown:
   <!– example changing port used to access remote Alfresco server (default is 29080) –>
   <config evaluator="string-compare" condition="Remote">
      <remote>
         <endpoint>
            <id>alfresco-noauth</id>
            <name>Alfresco - unauthenticated access</name>
            <description>Access to Alfresco Repository WebScripts that do not require authentication</description>
            <connector-id>alfresco</connector-id>
            <endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
            <identity>none</identity>
         </endpoint>

         <endpoint>
            <id>alfresco</id>
            <name>Alfresco - user access</name>
            <description>Access to Alfresco Repository WebScripts that require user authentication</description>
            <connector-id>alfresco</connector-id>
            <endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
            <identity>user</identity>
         </endpoint>

         <endpoint>
            <id>alfresco-feed</id>
            <name>Alfresco Feed</name>
            <description>Alfresco Feed - supports basic HTTP authentication via the EndPointProxyServlet</description>
            <connector-id>http</connector-id>
            <endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
            <basic-auth>true</basic-auth>
            <identity>user</identity>
         </endpoint>
      </remote>
   </config>
   

So what am I doing wrong? thanks

@ croc session.ticket doesn't work

mikeh
Star Contributor
Star Contributor
Could you post some of your code please? It's not obvious what you're trying to do.

Thanks,
Mike

jelena
Champ in-the-making
Champ in-the-making
Code is not really important now because when I hit this link in my browser I get nothing so the same thing happens inside js script:

var scriptURL= "http://localhost:29080/share/proxy/alfresco/test/fetchP";
var connector = remote.connect("http");
var result = connector.call(scriptURL);

result is empty.

But if I set scriptURL = http://localhost:8080/alfresco/service/test/fetchP, I get 401 unauthorized

So is my share/proxy link correct?

Tnx

mikeh
Star Contributor
Star Contributor
The code is important  :wink:

You need to use
remote.connect(ENDPOINT_ID);
i.e.
remote.connect("alfresco");

Thanks,
Mike

jelena
Champ in-the-making
Champ in-the-making
Thanks very much, this worked for me Smiley Happy