<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Service Access Policy - how to apply it</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=114629629" />
  <subtitle>Service Access Policy - how to apply it</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=114629629</id>
  <updated>2026-04-04T13:23:27Z</updated>
  <dc:date>2026-04-04T13:23:27Z</dc:date>
  <entry>
    <title>RE: Service Access Policy - how to apply it</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114647497" />
    <author>
      <name>Pete Helgren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114647497</id>
    <updated>2019-08-07T21:34:20Z</updated>
    <published>2019-08-07T21:34:20Z</published>
    <summary type="html">Thanks...&lt;br /&gt;&lt;br /&gt;Hmmm.  OK  I tried that but perhaps I did it wrong.  I added the p_auth token to the end of the url like this:&lt;br /&gt;&lt;br /&gt; https://api.mydomain.org/api/jsonws/mycore.lesson/get-lesson-resources/class-number/98765/locale-cd/en/lang/en /p_auth/MYTOKEN&lt;br /&gt;&lt;br /&gt;I still get access denied when I toggle OFF the &amp;#34;Default&amp;#34; even though the method is whitelisted and the IP is whitelisted.&lt;br /&gt;&lt;br /&gt;Not sure what the next step would be.  I wish there was a trace option so I could see where the security is failing.....</summary>
    <dc:creator>Pete Helgren</dc:creator>
    <dc:date>2019-08-07T21:34:20Z</dc:date>
  </entry>
  <entry>
    <title>RE: Service Access Policy - how to apply it</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114646651" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114646651</id>
    <updated>2019-08-07T19:48:16Z</updated>
    <published>2019-08-07T19:48:16Z</published>
    <summary type="html">I think if you don&amp;#39;t have a p_auth token, you may need to use an alternate authentication mechanism such as the basic auth header.&lt;br /&gt;&lt;br /&gt;The problem I have with the IP address filter is that, by turning it on, you affect the ability of the end user&amp;#39;s browsers being able to invoke services back on the portal.&lt;br /&gt;&lt;br /&gt;While there is probable some use cases for it, I&amp;#39;m not sure it works so well in the general cases...</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2019-08-07T19:48:16Z</dc:date>
  </entry>
  <entry>
    <title>RE: Service Access Policy - how to apply it</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114642804" />
    <author>
      <name>Pete Helgren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114642804</id>
    <updated>2019-08-07T15:50:58Z</updated>
    <published>2019-08-07T15:50:58Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;OK.&amp;nbsp; I get the fact that portal-ext.propeties entries are blunt.&amp;nbsp; So what would be the next step?&amp;nbsp; I did add the IP to the whitelist, yet any IP can still connect, regardless of that entry.&amp;nbsp; I did restart LR after making that change.&lt;br&gt;&lt;br&gt;So, IP restrictions do not appear to be enough.&amp;nbsp;&amp;nbsp; The control panel settings on the Service Access Policy allow me add the methods I want to the "whitelist".&amp;nbsp; Done!&amp;nbsp; At the top of that page I see an "Enable" toggle and a "Default" toggle.&amp;nbsp; When&amp;nbsp; I enable the policy but do not toggle ON the "Default".&amp;nbsp; I cannot connect remotely to the API, even though my IP is whitelisted and the method is whitelisted.&amp;nbsp; When I toggle on "Default" I CAN&amp;nbsp; access the API remotely, but so can any other IP address on the planet.&amp;nbsp; So, the "Default" setting seems to override just about everything and let anyone access the API.&lt;br&gt;&lt;br&gt;So, here are the steps as summaried in this knowledge base article:&amp;nbsp; https://portal.liferay.dev/docs/7-0/deploy/-/knowledge_base/d/securing-liferays-remote-services&lt;br&gt;&lt;br&gt;&lt;ol style="list-style: decimal outside;" start="1"&gt;&lt;li&gt;The IP address must be pre-configured in the server’s &lt;pre&gt;&lt;code&gt;portal-ext.properties&lt;/code&gt;&lt;/pre&gt; file.&lt;/li&gt;&lt;li&gt;At least one service access policy which applies to the request must have the API function being invoked in a whitelist.&lt;/li&gt;&lt;li&gt;If a browser is making the web service invocation request, a valid authentication token (&lt;pre&gt;&lt;code&gt;p_auth&lt;/code&gt;&lt;/pre&gt; URL parameter) must be provided.&lt;/li&gt;&lt;li&gt;The user ID being used must have permission to access the resources it attempts to access.&lt;/li&gt;&lt;/ol&gt; #1 and #2 have been done.&amp;nbsp; #3 doesn't apply since this is not a call from a browser.&amp;nbsp; So the only remaining question is with #4.&amp;nbsp; Do I need to ALSO provide a USERID in order to access the API? &lt;br&gt;&lt;br&gt;Thanks for your help with this.&amp;nbsp;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Pete Helgren</dc:creator>
    <dc:date>2019-08-07T15:50:58Z</dc:date>
  </entry>
  <entry>
    <title>RE: Service Access Policy - how to apply it</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114630246" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114630246</id>
    <updated>2019-08-07T02:11:52Z</updated>
    <published>2019-08-07T02:11:52Z</published>
    <summary type="html">Those properties are not related to the service access policies.&lt;br /&gt;&lt;br /&gt;They are overall controls over where connections can be established from. They are extremely blunt instruments that dictate what IPs can connect.&lt;br /&gt;&lt;br /&gt;The linked documentation tells how you can define a service access policy of your own &lt;strong&gt;from within the control panel&lt;/strong&gt;, not via portal-ext.properties.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2019-08-07T02:11:52Z</dc:date>
  </entry>
  <entry>
    <title>Service Access Policy - how to apply it</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114629628" />
    <author>
      <name>Pete Helgren</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114629628</id>
    <updated>2019-08-07T01:57:19Z</updated>
    <published>2019-08-07T01:57:19Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;I thought I had things locked down on my portlet using this guide from the Knowledge base: https://portal.liferay.dev/docs/7-0/deploy/-/knowledge_base/d/service-access-policies&amp;nbsp; I am using the " &lt;strong&gt;IP permission layer:&lt;/strong&gt; " approach.&amp;nbsp; I added the whitelisted IP to these two entries in portal.properties file:&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; #
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; # See the properties "main.servlet.hosts.allowed" and
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; # "main.servlet.https.required" on how to protect this servlet.
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; #
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; jsonws.servlet.hosts.allowed=xxx.xxx.xxx.xxx, 127.0.0.1, SERVER_$
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; jsonws.servlet.https.required=false

&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; json.servlet.hosts.allowed=xxx.xxx.xxx.xxx, 127.0.0.1, SERVER_IP
&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp; json.servlet.https.required=false&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;My IP in this case represented by the xxx.xxx.xxx.xxx &lt;br&gt;&lt;br&gt;If I call the API remotely like this: https://api.mydomain.org/api/jsonws/mycore.lesson/get-lesson-resources/class-number/98765/locale-cd/en/lang/en&amp;nbsp; Then I get an error message:&lt;br&gt;&lt;br&gt;  "Access denied to org.mydomain.api.core.service.LessonService#getLessonResources"&lt;br&gt;&lt;br&gt;The method is listed in the Allowed Service Signatures list.&amp;nbsp; The ONLY way so far to get access to the API is to use the "Default" on the service access policy.&amp;nbsp; Then I can get a JSON response with the content from the api.&lt;br&gt;&lt;br&gt;So, am I doing this wrong?&amp;nbsp; Are the "Layers" described in the knowledge base ALL needed?&amp;nbsp; Do I need something in addition to the IP entries in portal-ext.properties?&lt;br&gt;&lt;br&gt;It seems like it should be simple, but I am not getting it sorted out....&lt;br&gt;&lt;br&gt;Liferay 7.0 GA5&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Pete Helgren</dc:creator>
    <dc:date>2019-08-07T01:57:19Z</dc:date>
  </entry>
</feed>
