<?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>Fri, 29 Mar 2019 05:49:26 -0400</lastBuildDate><item><title>Comment by Stelt0 on Andreas Rusch's answer</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#3758</link><description>&lt;p&gt;I`m waiting for this feature quite a while :)&lt;/p&gt;
&lt;p&gt;I`m connecting the pieces now:
&lt;a href="https://answers.axonivy.com/questions/1858/rest-service-security"&gt;https://answers.axonivy.com/questions/1858/rest-service-security&lt;/a&gt;
&lt;a href="https://answers.axonivy.com/questions/1837/ajax-call-from-html-dialog-to-consume-web-service-and-rest-service"&gt;https://answers.axonivy.com/questions/1837/ajax-call-from-html-dialog-to-consume-web-service-and-rest-service&lt;/a&gt;
&lt;a href="https://answers.axonivy.com/questions/1828/using-modern-javascript-frameworks"&gt;https://answers.axonivy.com/questions/1828/using-modern-javascript-frameworks&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks a lot for addressing it !&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Stelt0</dc:creator><pubDate>Fri, 29 Mar 2019 05:49:26 -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#3758</guid></item><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><item><title>Comment by Alex Suter on Genzer Hawker's question</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#2474</link><description>&lt;p&gt;You asked also "I'm aware of the javax.annotation.security.PermitAll/DenyAll (-- which seems to be the only annotations supported?":&lt;/p&gt;
&lt;p&gt;We support next to &lt;code&gt;@DenyAll&lt;/code&gt; and &lt;code&gt;@PermitAll&lt;/code&gt; also &lt;code&gt;@RolesAllowed&lt;/code&gt;. Look at the &lt;code&gt;com.axonivy.connectivity.rest.provider.SecureService&lt;/code&gt; class in the Axon.ivy sample project "ConnectivityDemos".&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Alex Suter</dc:creator><pubDate>Thu, 02 Mar 2017 11:40:25 -0500</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#2474</guid></item><item><title>Comment by Genzer Hawker on Genzer Hawker's question</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#2467</link><description>&lt;p&gt;Hi &lt;a href="http://answers.axonivy.com/users/17/reguel-wermelinger"&gt;&lt;a href="http://answers.axonivy.com/users/17/reguel-wermelinger"&gt;@Reguel Wermelinger&lt;/a&gt;&lt;/a&gt;, via an internal resource, I know that the JIRA issue &lt;a href="https://jira.axonivy.com/jira/browse/XIVY-1183"&gt;XIVY-1183&lt;/a&gt; will address the problem I asked. Looking forward to version 6.6. Please add the answer once the feature is implemented.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Genzer Hawker</dc:creator><pubDate>Thu, 23 Feb 2017 05:39:52 -0500</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#2467</guid></item><item><title>Comment by Genzer Hawker on Genzer Hawker's question</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#2466</link><description>&lt;p&gt;The user is authenticated (&lt;code&gt;Developer&lt;/code&gt; on designer). Even if the header &lt;code&gt;Cookie:JSESSIONID=XXXX; oam.Flash.RENDERMAP.TOKEN=-yyyyyy&lt;/code&gt; is transfered but it still require to input username and password. It seems the header &lt;code&gt;Basic XXXX&lt;/code&gt; is not present so it (Jersey) will automatically assume the &lt;code&gt;UserPrinciple&lt;/code&gt; is not initialized. The filter does not check the Cookie though.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Genzer Hawker</dc:creator><pubDate>Wed, 22 Feb 2017 10:27:41 -0500</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#2466</guid></item><item><title>Comment by Reguel Wermelinger on Genzer Hawker's question</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#2465</link><description>&lt;p&gt;How did the user authenticate to access the HtmlDialog? I guess that if Basic AUTH was used to access the dialog, then the authentication headers will also be sent to follow up requests and therefore work for the REST api.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Wed, 22 Feb 2017 10:15:55 -0500</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#2465</guid></item><item><title>Comment by Genzer Hawker on Genzer Hawker's question</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#2464</link><description>&lt;p&gt;Hi &lt;a href="http://answers.axonivy.com/users/17/reguel-wermelinger"&gt;&lt;a href="http://answers.axonivy.com/users/17/reguel-wermelinger"&gt;@Reguel Wermelinger&lt;/a&gt;&lt;/a&gt;, I want to expose and then let the user consumes the RESTful API from the browser. In my setup, the RESTful classes and the JSF page are in the same project.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Genzer Hawker</dc:creator><pubDate>Wed, 22 Feb 2017 09:50:53 -0500</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#2464</guid></item><item><title>Comment by Reguel Wermelinger on Genzer Hawker's question</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#2463</link><description>&lt;p&gt;Did you try to use the plain JAX-RS api &lt;code&gt;javax.ws.rs.client.ClientBuilder.newClient()&lt;/code&gt; and re-use the returned instance of the client?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Wed, 22 Feb 2017 09:47:23 -0500</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#2463</guid></item></channel></rss>