<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Is it possible to access Ivy's RESTful API from an HtmlDialog or within the same session?</title><link>https://answers.axonivy.com/questions/2462/is-it-possible-to-access-ivy-s-restful-api-from-an-htmldialog-or-within-the-same-session</link><description>&lt;p&gt;Hi Ivy Team&lt;/p&gt;
&lt;p&gt;I have a HtmlDialog containing several links to our RESTful API (implemented using Axon.ivy). However, every time the user accesses to the API, the browser requires authentication even though the user has already logged in.&lt;/p&gt;
&lt;p&gt;I'm aware of the &lt;code&gt;javax.annotation.security.PermitAll/DenyAll&lt;/code&gt; (-- which seems to be the only annotations supported?) but I want to keep the Basic authentication intact.&lt;/p&gt;
&lt;p&gt;Say the page could be like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt; !-- The HelloWorld dialog --&amp;gt;
&amp;lt; h:html&amp;gt;
    &amp;lt; h:body&amp;gt;
        &amp;lt; h:outputLink value="/ivy/api/designer/helloworld" target="_blank"&amp;gt;
            Click to see Hello World
         &amp;lt; /h:outputLink&amp;gt;

        &amp;lt; h:outputLink value="/ivy/file/designer/session/some_file_already_created.txt" target="_blank"&amp;gt;
            Get content of file
        &amp;lt; /h:outputLink&amp;gt;
    &amp;lt; h:/body&amp;gt;
&amp;lt; /h:html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first link will require authentication whereas the second works normally.&lt;/p&gt;
&lt;p&gt;Is there a possible way to overcome this?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/2462/is-it-possible-to-access-ivy-s-restful-api-from-an-htmldialog-or-within-the-same-session" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 14 Mar 2019 10:29:19 -0400</lastBuildDate><item><title>Answer by Andreas Rusch</title><link>https://answers.axonivy.com/questions/2462/is-it-possible-to-access-ivy-s-restful-api-from-an-htmldialog-or-within-the-same-session/3740</link><description>&lt;h2&gt;&lt;strong&gt;LE Version 7.1+:&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Since version 7.1 the Ivy Engine is able to reuse the authenticated session for the REST service call. This was implemented with &lt;a href="https://jira.axonivy.com/jira/browse/XIVY-1183"&gt;XIVY-1183&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Note that the Engine will check for the CSRF (X-Requested-By) mitigation in the header. See chapter &lt;a href="https://developer.axonivy.com/doc/latest/DesignerGuideHtml/ivy.integration.html#ivy-integration-rest"&gt;Engine REST Integration&lt;/a&gt; in our documentation.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;LTS Version 7.0.11+:&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;We applied these changes to the LTS version 7.0.11 (story &lt;a href="https://jira.axonivy.com/jira/browse/XIVY-3119"&gt;XIVY-3119&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Note that by default this feature is switched off and the Engine is also not checking for the CSRF header token.
In order to enable the session reuse you need to set the following Java system properties to &lt;code&gt;true&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;IVY_REST_SERVLET_SESSION_REUSE&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;IVY_REST_SERVLET_CSRF_PROTECTION&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For security reasons it is highly recommended to enable the CSRF mitigation when enabling the REST session reuse.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Andreas Rusch</dc:creator><pubDate>Thu, 14 Mar 2019 10:29:19 -0400</pubDate><guid>https://answers.axonivy.com/questions/2462/is-it-possible-to-access-ivy-s-restful-api-from-an-htmldialog-or-within-the-same-session/3740</guid></item></channel></rss>