<?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 Re: How is the user chosen for no authentication web scripts? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13611#M6022</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a custom webscript using Javascript. I assume AuthenticationUtil is similar to specifying &amp;lt;authentication&amp;gt;{none, user, admin, etc.}&amp;lt;/authentication&amp;gt; in the desc.xml file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Aug 2017 13:20:30 GMT</pubDate>
    <dc:creator>thmsdrew</dc:creator>
    <dc:date>2017-08-17T13:20:30Z</dc:date>
    <item>
      <title>How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13609#M6020</link>
      <description>Hi all,Just curious... if I have a web script with no &amp;lt;authentication&amp;gt; tag in the definition XML, and let's say this web script is responsible for updating document properties, how is the user that the web script runs as chosen? I have seen some very inconsistent results and I'm curious as to</description>
      <pubDate>Thu, 17 Aug 2017 00:16:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13609#M6020</guid>
      <dc:creator>thmsdrew</dc:creator>
      <dc:date>2017-08-17T00:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13610#M6021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you write your webscript's code, at least using Java, you can use the AuthenticationUtil to run your code as a named user, or as System, with higher privileges.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You said you are seeing inconsistent results. Is this a custom webscript or one of the OOTB ones?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 13:04:34 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13610#M6021</guid>
      <dc:creator>douglascrp</dc:creator>
      <dc:date>2017-08-17T13:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13611#M6022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a custom webscript using Javascript. I assume AuthenticationUtil is similar to specifying &amp;lt;authentication&amp;gt;{none, user, admin, etc.}&amp;lt;/authentication&amp;gt; in the desc.xml file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 13:20:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13611#M6022</guid>
      <dc:creator>thmsdrew</dc:creator>
      <dc:date>2017-08-17T13:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13612#M6023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Take a look at this link&amp;nbsp;&lt;A class="link-titled" href="http://docs.alfresco.com/5.0/references/api-wsdl-authentication.html" title="http://docs.alfresco.com/5.0/references/api-wsdl-authentication.html" rel="nofollow noopener noreferrer"&gt;authentication | Alfresco Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see, you can have an webscript the does not enforce the authentication (with the none) parameter, but that is executed as a nominated user, using the runas parameter.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 13:35:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13612#M6023</guid>
      <dc:creator>douglascrp</dc:creator>
      <dc:date>2017-08-17T13:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13613#M6024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I'm wondering specifically how a user is chosen if the &amp;lt;authentication&amp;gt; element (which is optional in the first place) is not provided at all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 13:40:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13613#M6024</guid>
      <dc:creator>thmsdrew</dc:creator>
      <dc:date>2017-08-17T13:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13614#M6025</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From the &lt;A href="https://www.packtpub.com/web-development/learning-alfresco-web-scripts" rel="nofollow noopener noreferrer"&gt;Learning Alfresco Web Script book&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;If you are deploying a JavaScript-backed web script using&amp;nbsp;the repository option, make sure that the web script has the&amp;nbsp;authentication level set and it should not be set as none.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If you do not include&amp;nbsp;the authentication section, the the none option is the default. Again, from the same book:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;This is the default value when the authentication tag is also not specified in the&amp;nbsp;description document. It indicates that there isn't any authentication required to run&amp;nbsp;the web script.&lt;/P&gt;&lt;P&gt;In a web script that has authentication specified as none,&amp;nbsp;it will not be possible to interact with the repository.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Can you describe the &lt;EM&gt;inconsistent result&lt;/EM&gt; you are seeing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 13:55:21 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13614#M6025</guid>
      <dc:creator>douglascrp</dc:creator>
      <dc:date>2017-08-17T13:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13615#M6026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basically, the web script is responsible for updating a bunch of documents' properties. First it executes a query via the search API, then it updates a property, then saves for each document returned. I was getting inconsistent errors, but also sometimes it would work. These are the scenarios...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. It runs successfully, but the documents are showing as updated by a random user... not a user that ran the script, and not the same user each time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. It returns instantly with no error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. It returns instantly with an "access denied - user does not have the authorization to perform this operation" error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. It returns instantly with a "Query could not be executed" error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the way, I've resolved this issue by adding user authentication and passing in an alf_ticket value in the URL... but I'm just curious about why it was behaving so weird in the first place.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 14:47:05 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13615#M6026</guid>
      <dc:creator>thmsdrew</dc:creator>
      <dc:date>2017-08-17T14:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13616#M6027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Normally, if you use authentication "none", then there will be no authenticated user active and there should not be a "random user" being picked for modifier etc. BUT, I have seen a lot of 3rd-party code that messes up authentication handling.&lt;/P&gt;&lt;P&gt;E.g. if you do a AuthenticationUtil.setRunAsUser(xy) then you are setting that user in the thread context. If that context is not reset at the end of handling a request, then it stays tied to the thread. Since Tomcat reuses threads for HTTP calls (non-predictively, so you could call it "random"), any future request that does not explicitly authenticate a user (like your "none" authentication web script) may "accidentally" run in that user context if it gets processed by the affected thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have rarely seen a valid use case for working with authentication "none". If you do, always use the callback-based AuthenticationUtil.runAsUser(callback, user) variant. NEVER EVER use AuthenticationUtil.setRunAsUser(user) code because chances are - once in a while - you will forget to properly clean up that context.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 20:45:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13616#M6027</guid>
      <dc:creator>afaust</dc:creator>
      <dc:date>2017-08-17T20:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13617#M6028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good information, thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm assuming that with user authentication configured, my JS web script handles resetting the context itself at the end of the script's run. Is that right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, when I had NO user authentication configured and a seemingly "random" user was being chosen... does this mean we may have other code that is not properly cleaning up its context?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2017 13:22:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13617#M6028</guid>
      <dc:creator>thmsdrew</dc:creator>
      <dc:date>2017-08-18T13:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13618#M6029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Correct, if you set the required authentication than the web script framework takes care to reset the thread-context after completion of the web script call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And yes, such a problem would mean that you have other code in the system that is not properly cleaning up its context. Finding such instances can be an annoyingly hard task. I&amp;nbsp;did this in one customer project by adding a servlet filter at the top of the web.xml to log out the currently set authentication context (via AuthenticationUtil.getRunAsAuthentication()) at the end of a request along with the URL / HTTP method of that request. That allowed me to pinpoint which requests were leaking for a follow-up analysis of the code handling those URLs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2017 13:42:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13618#M6029</guid>
      <dc:creator>afaust</dc:creator>
      <dc:date>2017-08-18T13:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13619#M6030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excellent. Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2017 13:52:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13619#M6030</guid>
      <dc:creator>thmsdrew</dc:creator>
      <dc:date>2017-08-18T13:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13620#M6031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there anything else at all that will set the user context but free up the thread without clearing that context? Like logging into the share GUI and performing any actions there?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We don't really have a lot of custom code. I believe all of our custom code are web scripts with user authentication specified.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2017 14:06:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13620#M6031</guid>
      <dc:creator>thmsdrew</dc:creator>
      <dc:date>2017-08-18T14:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: How is the user chosen for no authentication web scripts?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13621#M6032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Only the HTTP requests to Alfresco Repository count for your case - Share only matters indirectly via the web scripts that get called from Share.&lt;/P&gt;&lt;P&gt;There are some sub-divisions that can be made, i.e. HTTP requests can only affect/infect the threads used by the Tomcat connector for handling HTTP requests and authentication issues do not "spread over" to background processes, while background processes / threads are isolated based on the thread pool / factory that is being used. If you are using a Tomcat executor thread pool, HTTP / HTTPS / AJP can&amp;nbsp;affect each other, otherwise those are isolated as well, which can help in pinpointing the type of&amp;nbsp;request that triggers it (e.g. if only HTTP is affected and your SOLR runs via HTTPS, it definitely will not have been caused by any of the SOLR data web scripts)&lt;/P&gt;&lt;P&gt;Most often I have seen such a problem with CRON-based jobs because those do not run in any authentication context by default and it is the responsibility of the implementer to do a runAsUser (and some are lazy and just to setRunAsUser instead).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2017 14:18:34 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-is-the-user-chosen-for-no-authentication-web-scripts/m-p/13621#M6032</guid>
      <dc:creator>afaust</dc:creator>
      <dc:date>2017-08-18T14:18:34Z</dc:date>
    </item>
  </channel>
</rss>

