1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2018 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-->
<sect1 id="wsacl"><title>Web Services ACL (Access Control List)</title>
<para>Virtuoso provides a generic access control list for HTTP and other
Internet protocol clients. This mechanism uses wildcard expressions to
selectively block and allow ranges of IP addresses. An ordered set of patterns
is matched against the origin of the request. The first matching pattern's
allow/deny flag determines whether the client is approved or not. </para>
<para>The patterns for designating a range of IP addresses follow the syntax of
the SQL 'LIKE' predicate; i.e. '%.foo.bar' or '*.foo.bar' for example.</para>
<tip><title>See Also:</title>
<para>The <link linkend="LikePredicate">LIKE Predicate & Search Patterns</link> section.</para>
</tip>
<para>The following mechanisms for services access restriction are
defined by default:</para>
<simplelist>
<member><emphasis>Web Server ACL</emphasis> - controls access to the Web server (basic fire wall)</member>
<member><emphasis>Web Proxy server ACL</emphasis> - controls access to the Web proxy server</member>
<member><emphasis>News Server ACL</emphasis> - controls access to the Internet news groups (reading or posting)</member>
</simplelist>
<sect2 id="wsaclgenpurpacl"><title>General purpose ACLs</title>
<para>The system table <computeroutput>DB.DBA.HTTP_ACL</computeroutput>
is used to persist ACL definitions, which can be managed with simple INSERT/UPDATE/DELETE statements. The table has the following layout:</para>
<para>Columns for DB.DBA.HTTP_ACL:</para>
<simplelist>
<member><emphasis>HA_LIST</emphasis> - ACL name </member>
<member><emphasis>HA_ORDER</emphasis> - Position in the list</member>
<member><emphasis>HA_OBJECT</emphasis> - Object ID (applicable to news groups also)</member>
<member><emphasis>HA_CLIENT_IP</emphasis> - *PATTERN*</member>
<member><emphasis>HA_FLAG</emphasis> - Allow/Deny flag, 0 - allow, 1 - deny</member>
<member><emphasis>HA_RW</emphasis> - Read/Write flag, 0 - read, 1 - post</member>
<member><emphasis>HA_DEST_IP</emphasis> - Destination IP/Host (applicable to the proxy also)</member>
<member><emphasis>HA_RATE</emphasis> - Rate Limit</member>
</simplelist>
<para>The primary key covers columns HA_LIST, HA_ORDER, HA_CLIENT_IP
and HA_FLAG.</para>
<tip><title>See Also</title>
<para>The full schema is listed in the Appendix under <link linkend="tables.db.dba.http_acl">System Tables</link>.</para>
</tip>
<formalpara><title>HA_LIST (required)</title>
<para>Name of the ACL, This is a label to designate a group of rules applicable to a specific
service. There are three pre-defined groups which are: HTTP, NEWS,
PROXY. Please note that name of group is treated as
case-insensitive string. In other words we can think about HA_LIST as domain
of the ACL. Developers can use that table to add their own ACLs , and use them with
API functions which are discussed in the next section.</para></formalpara>
<formalpara><title>HA_ORDER (required)</title>
<para>Ordinal number of the rule within its list. This number
should be unique within a specific group to have a
well defined order of rule matching. Please note that if order is equal the one with
allow flag equal to zero (HA_FLAG value see below) takes precedence.
The order for applying rules for particular list is in ascending order i.e.
first will be applied the rule with the smallest value of
HA_ORDER.</para></formalpara>
<formalpara><title>HA_CLIENT_IP (required)</title>
<para> A pattern to designate separate IP address or group of addresses.
This is a string value as for 'LIKE' operator. Some example is: 192.168.*;
will match all hosts from local private network. </para></formalpara>
<formalpara><title>HA_FLAG (required)</title>
<para> A boolean; zero or positive number designating a rule to be applied
for matching address/host. The default option is zero (false) for allowed action;
positive (true) for denied action. So application may use it in reverse; but in that case
it needs to take in account the order precedence
(see HA_ORDER).</para></formalpara>
<formalpara><title>HA_OBJECT (optional)</title>
<para> An integer designating an ID used in predefined ACL for
Internet News groups to designate ID of the group. This can be used also in
other applications where one desires to apply different rules for different objects. We can think of it as a
sub list inside an ACL.</para></formalpara>
<formalpara><title>HA_RW (optional)</title>
<para> An integer designating a action to be restricted (read/write); used in
predefined Internet News groups ACL. </para></formalpara>
<formalpara><title>HA_DEST_IP (optional)</title>
<para> A string containing pattern to match another IP number;
this is used in Web Proxy server ACL. This can also be used in custom
application logic.</para></formalpara>
<formalpara><title>HA_RATE (optional)</title>
<para> An float for Rate Limit. The filter calculates hit rate average and
compares with limit for http acl rule. If it is larger then will drop connection.
Once per day the statistics will be reset.</para>
<para>The Rate Limit UI can be configured from Conductor->System Admin->Security->Access Control where:</para>
<itemizedlist mark="bullet">
<listitem>Regular expressions are not supported.</listitem>
<listitem>Can be used patterns, for ex:
<programlisting><![CDATA[
-- like '%something' or
-- something*
]]></programlisting>
</listitem>
</itemizedlist>
<para>Rate limit is hits/per second from one IP address.</para>
<para>For search engine optimization statistics, for example can be set rate limit 10 (or even 100 so to
start to collect statistics), and then to check with http_acl_stats () what values are returned.</para>
</formalpara>
</sect2>
<sect2 id="wsacldefrem"><title>ACL Definition/Removal</title>
<para>ACL's can be managed from the administration web interface using the
following steps.</para>
<itemizedlist>
<listitem>From Admin UI main menu open "System Admin" node.</listitem>
<listitem>Go to Security -> Access Control</listitem>
<listitem>By default three default ACLs are listed:
<simplelist>
<member>HTTP - rules for the Web server </member>
<member>NEWS - rules for the Internet News</member>
<member>PROXY - rules for the Web Proxy Server</member>
<member>PSH and PSH-SSL - available only when the
<ulink url="http://s3.amazonaws.com/opldownload/uda/vad-packages/6.1/virtuoso/pubsubhub_dav.vad">pubsubhub_dav.vad</ulink>
is installed.</member>
</simplelist>
<figure id="admacl1" float="1">
<title>Access Control</title>
<graphic fileref="ui/admacl.png"/>
</figure>
</listitem>
<listitem>New ACLs can be added by entering a list name and clicking "Add" button.</listitem>
<listitem>Existing ACLs can be edited by clicking on the link "Edit" beside
each listed ACL. </listitem>
<listitem>To add new rules, enter the requested information and press
button "Add".</listitem>
<listitem>To change the order of the rules use the "top", "bottom", "up" and "down" links.</listitem>
<listitem>ACL's can be removed using the Delete button.</listitem>
</itemizedlist>
<para>Alternately the HTTP_ACL table can be directly manipulated with SQL.
To add new rule:</para>
<programlisting><![CDATA[
INSERT INTO HTTP_ACL (HA_LIST, HA_ORDER, HA_CLIENT_IP, HA_RATE, HA_FLAG) values
('list_name', <order number>, '*pattern*', <hits_per_second_number>, [1/0]);
]]></programlisting>
<para>To remove existing rule:</para>
<programlisting><![CDATA[
DELETE from HTTP_ACL where HA_LIST = 'list_name' and HA_ORDER = <order number>
and HA_FLAG = [1/0] and HA_CLIENT_IP = '*pattern*';
]]></programlisting>
</sect2>
<sect2 id="wsaclusing"><title>Using ACL's Within Application Logic</title>
<para>The
<link linkend="fn_http_acl_get"><function>http_acl_get()</function></link>
function can be used to test an address against an ACL. The
<link linkend="fn_http_client_ip"><function>http_client_ip()</function></link>
function can be used to determine the IP address or DNS name of a client
machine.</para>
<example id="ex_wsaclwithapps"><title>Using ACL's with Application Logic</title>
<para>To restrict a 'foo.bar' (network 333.333.333.0) from accessing a SOAP
service one could use the following:</para>
<programlisting><![CDATA[
-- deny access from '333.333.333.*'
insert into http_acl (ha_list, ha_order, ha_flag, ha_client_ip) values ('MY_SOAP', 1, 1, '333.333.333.*');
-- allow
insert into http_acl (ha_list, ha_order, ha_flag, ha_client_ip) values ('MY_SOAP', 2, 0, '*');
-- a procedure exposed as SOAP service
create procedure SumService (in a int, in b int) returns int
{
if (0 <> http_acl_get ('MY_SOAP', http_client_ip ()))
signal ('42000', 'Access denied');
return (a + b);
}
]]></programlisting>
</example>
</sect2>
<sect2 id="wsaclpredefined"><title>Predefined ACLs</title>
<para>The following ACLs are predefined and have special treatment in Web Server
processing:</para>
<formalpara><title>HTTP</title>
<para>General Web server ACL, applying rules to
it controls access to the Web server. Thus if this ACL is managed via web UI one
must pay attention not to disable the current connection and render the administration UI inaccessible. The ACL rules for 'HTTP' must contain HA_ORDER,
HA_CLIENT_IP (pattern) and HA_FLAG (access flag) only. The rest of column
values are ignored. To add or remove rules to that list see 'ACL definition/removal'
where HA_LIST must be equal to 'HTTP'. The value of client's IP address will
be tested against rules.</para></formalpara>
<formalpara><title>NEWS</title>
<para>controls access to the separate Internet News groups, restricting
POST or READ access to them. </para></formalpara>
<para>All valid rules for 'HTTP' are also valid for 'NEWS' with following difference: </para>
<simplelist>
<member>HA_OBJECT must be specified as ID of News group to control</member>
<member>HA_RW must be specified as 0/1 to designate which action on group to control: read or post.</member>
</simplelist>
<para>The HA_LIST must be equal to 'NEWS' if control is managed with SQL statements.
The HA_LIST must be equal to 'NEWS'.</para>
<formalpara><title>PROXY</title>
<para>This controls access to the Web Proxy Server. Note that Proxy service is
disabled by default and can be enabled with 'HTTPProxyEnabled' INI setting.
This ACL is similar to the HTTP ACL. Additionally, the pattern in HA_DEST_PATTERN must match the destination server.
In this way certain destinations can be restricted.</para></formalpara>
<note><title>Note:</title>
<para>HTTP ACLs affect PROXY rules. Therefore if HTTP list rejects a request
from a particular client, the proxy access from there also will be rejected. </para></note>
<example id="ex_wsacl"><title>Adding/removing ACL's</title>
<para>To allow access from localhost only:</para>
<programlisting><![CDATA[
insert into http_acl (ha_list, ha_order, ha_flag, ha_client_ip) values ('HTTP', 1, 0, '127.0.0.1');
insert into http_acl (ha_list, ha_order, ha_flag, ha_client_ip) values ('HTTP', 2, 1, '*');
]]></programlisting>
<para>To allow only local addresses (private.net/192.168.0.0) to access proxy server.</para>
<programlisting><![CDATA[
insert into http_acl (ha_list, ha_order, ha_flag, ha_client_ip, ha_dest_ip)
values ('PROXY', 1, 0, '192.168.1.*', '*');
insert into http_acl (ha_list, ha_order, ha_flag, ha_client_ip, ha_dest_ip)
values ('PROXY', 2, 1, '*', '*');
]]></programlisting>
<para>To deny web access from some domain (bad.domain/333.333.333.0)</para>
<programlisting><![CDATA[
insert into http_acl (ha_list, ha_order, ha_flag, ha_client_ip) values ('HTTP', 1, 0, '*');
insert into http_acl (ha_list, ha_order, ha_flag, ha_client_ip) values ('HTTP', 2, 1, '333.333.333.*');
]]></programlisting>
</example>
</sect2>
</sect1>
|