<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Authentication woes on share REST API in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/authentication-woes-on-share-rest-api/m-p/302839#M255969</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to ultimately get a CSRF token to post to create-site. I start with the share login to get the JSESSIONID.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On executing the below, I have the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;curl –junk-session-cookies -L -H "Content-Type: application/x-www-form-urlencoded" –cookie-jar cookies.txt –cookie cookies.txt -H "Origin: &lt;/SPAN&gt;&lt;A href="http://localhost:8080" rel="nofollow noopener noreferrer"&gt;http://localhost:8080&lt;/A&gt;&lt;SPAN&gt;" -D headers.txt -e "&lt;/SPAN&gt;&lt;A href="http://localhost:8080/;auto" rel="nofollow noopener noreferrer"&gt;http://localhost:8080/;auto&lt;/A&gt;&lt;SPAN&gt;" -X POST -d "username=username&amp;amp;password=password" &lt;/SPAN&gt;&lt;A href="http://localhost:8080/share/page/dologin" rel="nofollow noopener noreferrer"&gt;http://localhost:8080/share/page/dologin&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(u/n and p/w disguised for obvious reasons)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This gives an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;javax.servlet.ServletException: Possible CSRF attack noted when comparing token in session and request header. Request: POST /share/page/user/admin/dashboard&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I've been informed this is natural, and the JSESSIONID is usable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I then do (to get a CSRF token) a get to create-site:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;curl –cookie cookies.txt –cookie-jar cookies.txt -H "Origin: &lt;/SPAN&gt;&lt;A href="http://localhost:8080" rel="nofollow noopener noreferrer"&gt;http://localhost:8080&lt;/A&gt;&lt;SPAN&gt;" -D headers.txt -e "&lt;/SPAN&gt;&lt;A href="http://localhost:8080/;auto" rel="nofollow noopener noreferrer"&gt;http://localhost:8080/;auto&lt;/A&gt;&lt;SPAN&gt;" "&lt;/SPAN&gt;&lt;A href="http://localhost:8080/share/service/modules/create-site?htmlid=alfresco-createSite-instance" rel="nofollow noopener noreferrer"&gt;http://localhost:8080/share/service/modules/create-site?htmlid=alfresco-createSite-instance&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;yields:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;…&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Alfresco.util.addMessages({"error.loggedOut": "Your user session has timed out, please login and try again", "label.type": "Type", "title.collaborationSite": "Collaboration Site", "label.isPrivate": "Private", "message.creating": "Site is being created…", "label.moderatedHelp": "Site managers can control who joins the site", "error.noPermissions": "Could not create site. You do not have permissions to perform this operation.", "error.duplicateShortName": "Could not create site since the URL is already used", "label.isPublic": "Public", "label.shortNameHelp": "This is used to access the site URL in your browser&amp;lt;br\/&amp;gt;and also when accessing the site through other protocols&amp;lt;br\/&amp;gt;such as WebDav.&amp;lt;br&amp;gt;Do not use spaces or special characters.", "header.createSite": "Create Site", "error.create": "Could not create the site at this time. Please try again later.", "label.isModerated": "Moderated site membership", "message.failure": "Could not create site", "label.access": "Visibility", "label.shortName": "URL Name"}, "Alfresco.module.CreateSite")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the same result with a correct or incorrect password at the initial step. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The finally I get negative results posting to create-site:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;curl –cookie cookies.txt -X POST –data @site.json -H "Content-Type:application/json;charset=UTF-8" -H "Origin: &lt;/SPAN&gt;&lt;A href="http://localhost:8080" rel="nofollow noopener noreferrer"&gt;http://localhost:8080&lt;/A&gt;&lt;SPAN&gt;" -H 'Alfresco-CSRFToken: zL91jbFfxMNVIL8+svbXPx4a3vakN4pQ6VMIEU0Djzo=' -D headers,txt -e "&lt;/SPAN&gt;&lt;A href="http://localhost:8080/;auto" rel="nofollow noopener noreferrer"&gt;http://localhost:8080/;auto&lt;/A&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;A href="http://localhost:8080/share/service/modules/create-site" rel="nofollow noopener noreferrer"&gt;http://localhost:8080/share/service/modules/create-site&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "status" :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "code" : 400,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "name" : "Bad Request",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "description" : "Request sent by the client was syntactically incorrect."&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; }, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; "message" : "error.duplicateShortName", &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; "exception" : "",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; "callstack" :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; [&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; ],&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; "server" : "Spring WebScripts - v1.2.0 (Release 1549) schema 1,000",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; "time" : "18-Sep-2014 16:11:59"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, the very first time I did this, it worked and a site was created. Note the obvious – the shortname does not exist and I have checked and confirmed this with existing repo sites and generated new random shortnames and I still get the same results. Note these results are the same whether or not I use a correct or incorrect password at step 1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My initial indication is that there is a cookie lying around somewhere that Alfresco is looking at which I need to unset (although unlikely as I'm junking the session cookies (see curl command)), or I need to unset some state within Alfresco that it's holding on to.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Sep 2014 12:04:43 GMT</pubDate>
    <dc:creator>jocylincouch</dc:creator>
    <dc:date>2014-09-22T12:04:43Z</dc:date>
    <item>
      <title>Authentication woes on share REST API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/authentication-woes-on-share-rest-api/m-p/302839#M255969</link>
      <description>I'm trying to ultimately get a CSRF token to post to create-site. I start with the share login to get the JSESSIONID.On executing the below, I have the following:curl –junk-session-cookies -L -H "Content-Type: application/x-www-form-urlencoded" –cookie-jar cookies.txt –cookie cookies.txt -H "Origin:</description>
      <pubDate>Mon, 22 Sep 2014 12:04:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/authentication-woes-on-share-rest-api/m-p/302839#M255969</guid>
      <dc:creator>jocylincouch</dc:creator>
      <dc:date>2014-09-22T12:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Authentication woes on share REST API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/authentication-woes-on-share-rest-api/m-p/302840#M255970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use proxy servlet in share directly to call site WebScript API and don't need to reauthenticate again&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Oct 2014 02:03:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/authentication-woes-on-share-rest-api/m-p/302840#M255970</guid>
      <dc:creator>kaynezhang</dc:creator>
      <dc:date>2014-10-07T02:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Authentication woes on share REST API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/authentication-woes-on-share-rest-api/m-p/302841#M255971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Could you explain this more please?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Oct 2014 12:40:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/authentication-woes-on-share-rest-api/m-p/302841#M255971</guid>
      <dc:creator>jocylincouch</dc:creator>
      <dc:date>2014-10-15T12:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Authentication woes on share REST API</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/authentication-woes-on-share-rest-api/m-p/302842#M255972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't get the proxy stuff mentioned above, however if the decoded CSRF token is added in to header of the create-site POST request, then you will have a site successfully created. Don't forget all the other cookies, including the CSRF token cookie (but don't decode that one – leave it alone!).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Oct 2014 11:02:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/authentication-woes-on-share-rest-api/m-p/302842#M255972</guid>
      <dc:creator>jocylincouch</dc:creator>
      <dc:date>2014-10-21T11:02:35Z</dc:date>
    </item>
  </channel>
</rss>

