cancel
Showing results for 
Search instead for 
Did you mean: 

Webscript / API services authentication

tonyc
Champ in-the-making
Champ in-the-making
Hey all-

I'm having difficulties getting an authenticated web script to use those credentials when I call the download service from within the webscript…

Basically I've created a custom search/browse web-script for our documents and I am using ${url.context}/download/attach/workspace/SpacesStore/${result.id}/${result.name} as a link to the document to download it.  When a user clicks on it they have to re authenticate..

Can anyone out there point me to a fix for this


Thanks,
Tony
8 REPLIES 8

lista
Star Contributor
Star Contributor
Have you tried appending the ticket?

tonyc
Champ in-the-making
Champ in-the-making
No I have not.  I feel that the process of fetching a ticket, parsing it, then appending to a URL is unnecessary.  Login credentials were already established and I'm sure there's got to be a way to authenticate with those.

tonyc
Champ in-the-making
Champ in-the-making
Is there a ticket already established once you have authenticated the web-script that I could then append to the request..

gronfelt
Champ in-the-making
Champ in-the-making
If you authenticate using the Login or Login (POST) web scripts a ticket is returned, that could then be appended to your other requests.

tonyc
Champ in-the-making
Champ in-the-making
Thank you.. I was unaware that a ticket was already created under the session root object.  I swear I checked my JavaScript API wiki  Smiley Surprisedops:

stevegreenbaum
Champ in-the-making
Champ in-the-making
The web script I am developing generates a list of document from which the user selects one to open using MS Office via webdav (IE 8 - XP SP3).  The web script uses basic authentication - Windows presents a login screen before generating the list of documents.  In the web script Javascript controller after basic authentication I getTicket() and then use that ticket later to form the webdav url when the user selects a specific document; can the ticket I retrieved in the initial web script be used to authenticate the webdav call or any other subsequent servlet call?

I am still being prompted to login when the user selects the document from the list.  I am not sure if this ticket is invalid or I have some other problem.  I've tried using ?ticket= and ?alf_ticket= with the same result.  Must I use either the login web script or webservice to get a valid ticket? As a quick test, I invoked the Login webscript from the browser and generated a ticket and then hard coded that on the webdav url call.  It still prompts me to login.

The following link indicates that XP SP3 webdav driver has authentication issues.  I tried the registry change described by MS but this didn't solve the problem.   http://greenbytes.de/tech/webdav/webdav-redirector-list.html#issue-no-basic-auth

dward
Champ on-the-rise
Champ on-the-rise
The argument is called "ticket" and it should work. Note a webdav path should begin /webdav/

If you put this in log4j.properties

log4j.logger.org.alfresco.repo.webdav.auth=debug

You should see a DEBUG message in alfresco.log saying "Logon via ticket from …"

Are you using a different authentication chain or custom authentication filters?

stevegreenbaum
Champ in-the-making
Champ in-the-making
Are you using a different authentication chain or custom authentication filters?
No, I have not implemented chaining or authentication filters.

Webdav:

I turned on the logging as you suggested, but do not find a “login via ticket” message in the log.  The log output is at the bottom of this post and shows no ticket related messages. Here is the url I am using when opening an Office document for editing:

//localhost:8080/alfresco/webdav/User Homes/sgreenbaum/Test document 3.docx?ticket=TICKET_69a49e51c5cb140f53860581c0ce8ec94829c92d

The Office documents I am opening need to be opened with editing enabled (not read-only).  To open the document for editing I am using the same technique as used by the Alfresco client when Edit Online is selected (using webdav.js).  The first time I open an Office document I am prompted to log in, subsequent files open without logging in again.  However, if a non-Office document is opened in between, the system prompts for the login again the next time I open an Office document.  I suspect that the Sharepoint.Open command is interfering with the ticket. 

Also note that using this technique, I always receive the “Some files can harm your computer….” message which I have not be able to find a method to suppress (I’ve tried published workarounds, but with no success). 

Non-webdav:

For non-webdav links to the repository, the ticket is working fine and I am not prompted to log in again.  For example,
http://localhost:8080/alfresco/d/d/workspace/SpacesStore/fa72ed65-295b-4a98-aa0d-26bc948b21e3/Test%2...


Here is the log output:
11:10:16,515 DEBUG [org.alfresco.webdav.protocol] WebDAV request HEAD on path /alfresco/webdav/User%20Homes/sgreenbaum/Test%20document%203.docx
11:10:16,546 DEBUG [org.alfresco.webdav.protocol] HEAD took 31ms to execute
11:10:16,562 DEBUG [org.alfresco.webdav.protocol] WebDAV request HEAD on path /alfresco/webdav/User%20Homes/sgreenbaum/Test%20document%203.docx
11:10:16,593 DEBUG [org.alfresco.webdav.protocol] HEAD took 31ms to execute
11:10:16,640 DEBUG [org.alfresco.webdav.protocol] WebDAV request LOCK on path /alfresco/webdav/User%20Homes/sgreenbaum/Test%20document%203.docx
11:10:16,640 DEBUG [org.alfresco.webdav.protocol] Parsing If header: null
11:10:16,640 DEBUG [org.alfresco.webdav.protocol] Lock lockToken=null, timeout=180
11:10:16,640 DEBUG [org.alfresco.webdav.protocol] Locking node:
   user: admin
   path: /User Homes/sgreenbaum/Test document 3.docx
11:10:16,640 DEBUG [org.alfresco.webdav.protocol] Create lock status=NO_LOCK
11:10:16,734 DEBUG [org.alfresco.webdav.protocol] LOCK took 94ms to execute
11:10:16,750 DEBUG [org.alfresco.webdav.protocol] WebDAV request GET on path /alfresco/webdav/User%20Homes/sgreenbaum/Test%20document%203.docx
11:10:16,750 DEBUG [org.alfresco.webdav.protocol] GET took 0ms to execute
11:10:16,765 DEBUG [org.alfresco.webdav.protocol] WebDAV request HEAD on path /alfresco/webdav/User%20Homes/sgreenbaum/Test%20document%203.docx
11:10:16,765 DEBUG [org.alfresco.webdav.protocol] HEAD took 0ms to execute
11:10:16,796 DEBUG [org.alfresco.webdav.protocol] WebDAV request PROPFIND on path /alfresco/webdav/User%20Homes/sgreenbaum/Test%20document%203.docx
11:10:16,812 DEBUG [org.alfresco.webdav.protocol] PROPFIND took 16ms to execute
11:10:16,921 DEBUG [org.alfresco.webdav.protocol] WebDAV request PROPFIND on path /alfresco/webdav/User%20Homes/sgreenbaum/Test%20document%203.docx
11:10:16,937 DEBUG [org.alfresco.webdav.protocol] PROPFIND took 16ms to execute