Geo restriciton implementation

Implements blueprint: geo-restrictions

Change-Id: I5caa88cc140c2b9b2b8429084484e16a9eb42f24
This commit is contained in:
tonytan4ever 2015-03-11 12:04:41 -04:00
parent 8b52b9de9e
commit ba04bf5047
9 changed files with 825 additions and 4 deletions

View File

@ -0,0 +1,113 @@
# Copyright (c) 2014 Rackspace, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
GEO_REGION_ZONES = [
'North America',
'South America',
'EMEA(Europe, Middle East and Africa)',
'Japan',
'India',
'Australia',
'Rest Of APAC'
]
GEO_COUNTRY_ZONES = [
# North America
'Antigua and Barbuda',
'Aruba',
'Bahamas',
'Barbados',
'Belize',
'Bermuda',
'British Virgin Islands',
'Cayman Islands',
'Costa Rica',
'Cuba',
'Dominica',
'Dominican Republic',
'El Salvador',
'Greenland',
'Grenada',
'Guadeloupe',
'Guatemala',
'Haiti',
'Honduras',
'Jamaica',
'Martinique',
'Mexico',
'Montserrat',
'Netherlands Antilles',
'Nicaragua',
'USA',
'Canada',
'Panama',
'Puerto Rico',
'St Kitts and Nevis',
'St Lucia', 'St Pierre and Miquelon',
'St Vincent and The Grenadines', 'Trinidad and Tobago',
'Turks and Caicos Islands', 'Virgin', 'St Tome and Principe',
# South America
'Argentina', 'Bolivia', 'Brazil', 'Chile', 'Colombia',
'Costa Rica', 'Ecuador', 'Falkland Islands', 'French Guiana',
'Guyana', 'Paraguay', 'Peru', 'South Georgia and South Sanwich',
'Suriname', 'Uruguay', 'Venezuela',
# EMEA (Europe, Middle East and Africa)
'Albania', 'Algeria', 'Andorra', 'Angola', 'Austria', 'Bahrain',
'Belarus', 'Belgium', 'Benin', 'Bosnia and Herzegovina', 'Botswana',
'Bouvet Island', 'British Indian Ocean Territory', 'Bulgaria', 'Burkina',
'Burundi', 'Cameroon', 'Cape Verde', 'Central African Republic', 'Chad',
'Comoros', 'Congo', 'Cote D\'Ivoire', 'Croatia', 'Cyprus',
'Czech Republic', 'Democratic Republic of Congo', 'Denmark', 'Djibouti',
'Egypt', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia',
'Faeroe Islands', 'Finland', 'France',
'Gabon', 'Gambia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', 'Guinea',
'Guinea Bissau', 'Hungary', 'Iceland', 'Iran', 'Iraq', 'Ireland', 'Israel',
'Italy', 'Jordan, Kenya', 'Kuwait', 'Latvia', 'Lebanon', 'Lesotho',
'Liberia', 'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg',
'Macedonia', 'Madagascar', 'Malawi', 'Mali', 'Malta', 'Mauritania',
'Mauritius', 'Mayotte', 'Moldavia', 'Monaco', 'Morocco', 'Mozambique',
'Namibia', 'Netherlands', 'Niger', 'Nigeria', 'Norway', 'Oman', 'Poland',
'Portugal', 'Qatar', 'Reunion', 'Romania', 'Russia', 'Rwanda',
'San Marino', 'Saudi Arabia', 'Senegal, Seychelles', 'Sierra Leone',
'Slovakia', 'Slovenia', 'Somalia', 'South Africa', 'Spain',
'St Helena', 'Sudan', 'Svalbard', 'Swaziland', 'Sweden', 'Switzerland',
'Syria', 'Tanzania', 'Togo', 'Tunisia', 'Turkey', 'Uganda',
'United Arab Emirates', 'United Kingdom', 'Vatican City', 'Western Sahara',
'Yemen', 'Yugoslavia', 'Zambia', 'Zimbabwe',
# Japan:
'Japan',
# India
'India',
# Australia
'Australia',
'New Zealand',
# Rest Of APAC:
'Afghanistan', 'American Samoa', 'Antarctica', 'Armenia', 'Azerbaijan',
'Bangladesh', 'Bhutan', 'Brunei', 'Cambodia', 'Christmas Island',
'Cocos', 'Cook Islands', 'East Timor', 'Fiji', 'French Polynesia',
'French Southern Territories', 'Georgia', 'Guam',
'Heard and McDonald Islands', 'Hong Kong', 'Indonesia', 'Kazakhstan',
'Kiribati', 'Kyrgyzstan', 'Laos', 'Macau', 'Malaysia', 'Maldives',
'Marshall Islands', 'Micronesia', 'Mongolia', 'Myanmar', 'Nauru', 'Nepal',
'New Caledonia', 'Niue', 'Norfolk Island', 'North Korea',
'Northern Mariana Islands', 'Pakistan', 'Palau', 'Papua New Guinea',
'Philippines', 'Pitcairn'
]

View File

@ -13,7 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from poppy.common import util
from poppy.model import common
from poppy.model.helpers import geo_zones
class Rule(common.DictSerializableModel):
@ -34,6 +36,14 @@ class Rule(common.DictSerializableModel):
if http_method:
self._http_method = http_method
if geography:
# Validate the geography should be in a list of supported
# countries
if geography is not None and \
geography not in geo_zones.GEO_COUNTRY_ZONES and \
geography not in geo_zones.GEO_REGION_ZONES:
raise ValueError(util.help_escape(
'Country/Area %s is not supported in '
'geo zones' % geography))
self._geography = geography
if request_url:
self._request_url = request_url
@ -91,4 +101,11 @@ class Rule(common.DictSerializableModel):
@geography.setter
def geography(self, value):
if value is not None and \
value not in geo_zones.GEO_COUNTRY_ZONES and \
value not in geo_zones.GEO_REGION_ZONES:
raise ValueError(util.help_escape(
'Country/Area %s is not supported in '
'geo zones' % value))
self._geography = value

View File

@ -0,0 +1,374 @@
# Copyright (c) 2013 Rackspace, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from poppy.model.helpers import geo_zones
from poppy.openstack.common import log
# to use log inside worker, we need to directly use logging
LOG = log.getLogger(__name__)
REGION_COUNTRY_MAPPING = {
'North America': [
'Antigua and Barbuda',
'Aruba',
'Bahamas',
'Barbados',
'Belize',
'Bermuda',
'British Virgin Islands',
'Cayman Islands',
'Costa Rica',
'Cuba',
'Dominica',
'Dominican Republic',
'El Salvador',
'Greenland',
'Grenada',
'Guadeloupe',
'Guatemala',
'Haiti',
'Honduras',
'Jamaica',
'Martinique',
'Mexico',
'Montserrat',
'Netherlands Antilles',
'Nicaragua',
'USA',
'Canada',
'Panama',
'Puerto Rico',
'St Kitts and Nevis',
'St Lucia', 'St Pierre and Miquelon',
'St Vincent and The Grenadines', 'Trinidad and Tobago',
'Turks and Caicos Islands', 'Virgin', 'St Tome and Principe'],
'South America': [
'Argentina', 'Bolivia', 'Brazil', 'Chile', 'Colombia',
'Costa Rica', 'Ecuador', 'Falkland Islands', 'French Guiana',
'Guyana', 'Paraguay', 'Peru', 'South Georgia and South Sanwich',
'Suriname', 'Uruguay', 'Venezuela',
],
'EMEA(Europe, Middle East and Africa)': [
'Albania', 'Algeria', 'Andorra', 'Angola', 'Austria', 'Bahrain',
'Belarus', 'Belgium', 'Benin', 'Bosnia and Herzegovina', 'Botswana',
'Bouvet Island', 'British Indian Ocean Territory', 'Bulgaria',
'Burkina',
'Burundi', 'Cameroon', 'Cape Verde', 'Central African Republic',
'Chad',
'Comoros', 'Congo', 'Cote D\'Ivoire', 'Croatia', 'Cyprus',
'Czech Republic', 'Democratic Republic of Congo', 'Denmark',
'Djibouti',
'Egypt', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia',
'Faeroe Islands', 'Finland', 'France',
'Gabon', 'Gambia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', 'Guinea',
'Guinea Bissau', 'Hungary', 'Iceland', 'Iran', 'Iraq', 'Ireland',
'Israel',
'Italy', 'Jordan, Kenya', 'Kuwait', 'Latvia', 'Lebanon', 'Lesotho',
'Liberia', 'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg',
'Macedonia', 'Madagascar', 'Malawi', 'Mali', 'Malta', 'Mauritania',
'Mauritius', 'Mayotte', 'Moldavia', 'Monaco', 'Morocco', 'Mozambique',
'Namibia', 'Netherlands', 'Niger', 'Nigeria', 'Norway', 'Oman',
'Poland',
'Portugal', 'Qatar', 'Reunion', 'Romania', 'Russia', 'Rwanda',
'San Marino', 'Saudi Arabia', 'Senegal, Seychelles', 'Sierra Leone',
'Slovakia', 'Slovenia', 'Somalia', 'South Africa', 'Spain',
'St Helena', 'Sudan', 'Svalbard', 'Swaziland', 'Sweden', 'Switzerland',
'Syria', 'Tanzania', 'Togo', 'Tunisia', 'Turkey', 'Uganda',
'United Arab Emirates', 'United Kingdom', 'Vatican City',
'Western Sahara', 'Yemen', 'Yugoslavia', 'Zambia', 'Zimbabwe',
],
'Japan': [
'Japan'
],
'India': [
'India'
],
'Australia': [
'Australia',
'New Zealand'
],
'Rest Of APAC': [
'Afghanistan', 'American Samoa', 'Antarctica', 'Armenia', 'Azerbaijan',
'Bangladesh', 'Bhutan', 'Brunei', 'Cambodia', 'Christmas Island',
'Cocos', 'Cook Islands', 'East Timor', 'Fiji', 'French Polynesia',
'French Southern Territories', 'Georgia', 'Guam',
'Heard and McDonald Islands', 'Hong Kong', 'Indonesia', 'Kazakhstan',
'Kiribati', 'Kyrgyzstan', 'Laos', 'Macau', 'Malaysia', 'Maldives',
'Marshall Islands', 'Micronesia', 'Mongolia', 'Myanmar', 'Nauru',
'Nepal', 'New Caledonia', 'Niue', 'Norfolk Island', 'North Korea',
'Northern Mariana Islands', 'Pakistan', 'Palau', 'Papua New Guinea',
'Philippines', 'Pitcairn'
]
}
COUNTRY_CODE_MAPPING = {
# North America
'Antigua and Barbuda': 'AG',
'Aruba': 'AW',
'Bahamas': 'BS',
'Barbados': 'BB',
'Belize': 'BZ',
'Bermuda': 'BM',
'British Virgin Islands': 'VG',
'Cayman Islands': 'KY',
'Costa Rica': 'CR',
'Cuba': 'CU',
'Dominica': 'DM',
'Dominican Republic': 'DO',
'El Salvador': 'SV',
'Greenland': 'GL',
'Grenada': 'GD',
'Guadeloupe': 'GP',
'Guatemala': 'GT',
'Haiti': 'HT',
'Honduras': 'HN',
'Jamaica': 'JM',
'Martinique': 'MQ',
'Mexico': 'MX',
'Montserrat': 'MS',
'Netherlands Antilles': '',
'Nicaragua': 'NI',
'USA': 'US',
'Canada': 'CA',
'Panama': 'PA',
'Puerto Rico': 'PR',
'St Kitts and Nevis': 'KN',
'St Lucia': 'LC',
'St Pierre and Miquelon': 'PM',
'St Vincent and the Grenadines': 'VC',
'Trinidad and Tobago': 'TT',
'Turks and Caicos Islands': 'TC',
'Virgin': '',
'St Tome and Principe': 'ST',
# South America
'Argentina': 'AR',
'Bolivia': 'BO',
'Brazil': 'BR',
'Chile': 'CL',
'Colombia': 'CO',
'Costa Rica': 'CR',
'Ecuador': 'EC',
'Falkland Islands': 'FK',
'French Guiana': 'GF',
'Guyana': 'GA',
'Paraguay': 'PY',
'Peru': 'PE',
'South Georgia and South Sandwich': 'GS',
'Suriname': 'SR',
'Uruguay': 'UY',
'Venezuela': 'VE',
# EMEA (Europe Middle East and Africa)
'Albania': 'AL',
'Algeria': 'DZ',
'Andorra': 'AD',
'Angola': 'AO',
'Austria': 'AT',
'Bahrain': 'BH',
'Belarus': 'BY',
'Belgium': 'BE',
'Benin': 'BJ',
'Bosnia and Herzegovina': 'BA',
'Botswana': 'BW',
'Bouvet Island': 'BV',
'British Indian Ocean Territory': 'IO',
'Bulgaria': 'BG',
'Burkina': 'BF',
'Burundi': 'BI',
'Cameroon': 'CM',
'Cape Verde': '',
'Central African Republic': 'CF',
'Chad': 'TD',
'Comoros': 'KM',
'Congo': 'CG',
'Cote d\'Ivoire': 'CI',
'Croatia': 'HR',
'Cyprus': 'CY',
'Czech Republic': 'CZ',
'Democratic Republic of Congo': 'CD',
'Denmark': 'DK',
'Djibouti': 'DJ',
'Egypt': 'EG',
'Equatorial Guinea': 'GQ',
'Eritrea': 'ER',
'Estonia': 'EE',
'Ethiopia': 'ET',
'Faeroe Islands': 'FO',
'Finland': 'FI',
'France': 'FR',
'France (European Territory)': '',
'Gabon': 'GA',
'Gambia': 'GM',
'Germany': 'DE',
'Ghana': 'GH',
'Gibraltar': 'GI',
'Greece': 'GR',
'Guinea': 'GN',
'Guinea Bissau': 'GW',
'Hungary': 'HU',
'Iceland': 'IS',
'Iran': 'IR',
'Iraq': 'IQ',
'Ireland': 'IE',
'Israel': 'IL',
'Italy': 'IT',
'Jordan': 'JO',
'Kenya': 'KE',
'Kuwait': 'KW',
'Latvia': 'LV',
'Lebanon': 'LB',
'Lesotho': 'LS',
'Liberia': 'LR',
'Libya': 'LY',
'Liechtenstein': 'LI',
'Lithuania': 'LT',
'Luxembourg': 'LU',
'Macedonia': 'MK',
'Madagascar': 'MG',
'Malawi': 'MW',
'Mali': 'ML',
'Malta': 'MT',
'Mauritania': 'MR',
'Mauritius': 'MU',
'Mayotte': 'YT',
# Moldavia has become Moldova
# 'Moldavia': '',
'Monaco': 'MC',
'Morocco': 'MA',
'Mozambique': 'MZ',
'Namibia': 'NA',
'Netherlands': 'NL',
'Niger': 'NE',
'Nigeria': 'NG',
'Norway': 'NO',
'Oman': 'OM',
'Poland': 'PL',
'Portugal': 'PT',
'Qatar': 'QA',
'Reunion': 'RE',
'Romania': 'RO',
'Russia': 'RU',
'Rwanda': 'RW',
'San Marino': 'SM',
'Saudi Arabia': 'SA',
'Senegal Seychelles': 'SC',
'Sierra Leone': 'SL',
'Slovakia': 'SK',
'Slovenia': 'SI',
'Somalia': 'SO',
'South Africa': 'ZA',
'Spain': 'ES',
'St Helena': 'SH',
'Sudan': 'SD',
'Svalbard': 'SJ',
'Swaziland': 'SZ',
'Sweden': 'SE',
'Switzerland': 'CH',
'Syria': 'SY',
'Tanzania': 'TZ',
'Togo': 'TG',
'Tunisia': 'TN',
'Turkey': 'TR',
'Uganda': 'UG',
'United Arab Emirates': 'AE',
'United Kingdom': 'GB',
'Vatican City': 'VA',
'Western Sahara': 'EH',
'Yemen': 'YE',
# There is no Yugoslavia no more
# 'Yugoslavia': '',
'Zambia': 'ZM',
'Zimbabwe': 'ZW',
# Japan:
'Japan': 'JP',
# India
'India': 'IN',
# Australia
'Australia': 'AU',
'New Zealand': 'NZ',
# Rest Of APAC:
'Afghanistan': 'AF',
'American Samoa': 'AS',
'Antarctica': 'AQ',
'Armenia': 'AM',
'Azerbaijan': 'AZ',
'Bangladesh': 'BD',
'Bhutan': 'BT',
'Brunei': 'BN',
'Cambodia': 'KH',
'Christmas Island': 'CX',
'Cocos': 'CC',
'Cook Islands': 'CK',
'East Timor': 'TL',
'Fiji': 'FJ',
'French Polynesia': 'PF',
'French Southern Territories': 'TF',
'Georgia': 'GE',
'Guam': 'GU',
'Heard and Mcdonald Islands': 'HM',
'Hong Kong': 'HK',
'Indonesia': 'ID',
'Kazakhstan': 'KZ',
'Kiribati': 'KI',
'Kyrgyzstan': 'KG',
'Laos': 'LA',
'Macau': 'MO',
'Malaysia': 'MY',
'Maldives': 'MV',
'Marshall Islands': 'MH',
'Micronesia': 'FM',
'Mongolia': 'MN',
'Myanmar': 'MM',
'Nauru': 'NR',
'Nepal': 'NP',
'New Caledonia': 'NC',
'Niue': 'NU',
'Norfolk Island': 'NF',
'North Korea': 'KP',
'Northern Mariana Islands': 'MP',
'Pakistan': 'PK',
'Palau': 'PW',
'Papua New Guinea': 'PG',
'Philippines': 'PH',
'Pitcairn': 'PN'
}
for region in REGION_COUNTRY_MAPPING:
if region not in geo_zones.GEO_REGION_ZONES:
try:
raise ValueError('Unsupported region config')
except ValueError:
LOG.warn('Unsupported region: %s in GEO zone mapping' % region)
# validate COUNTRY_CODE_MAPPING keys are in GEO_ZONES'
for country in COUNTRY_CODE_MAPPING:
if country not in geo_zones.GEO_COUNTRY_ZONES:
try:
raise ValueError('Unsupported country config')
except ValueError:
LOG.warn('Unsupported country: %s in GEO zone mapping' % country)

View File

@ -21,6 +21,7 @@ import traceback
from poppy.common import decorators
from poppy.common import util
from poppy.openstack.common import log
from poppy.provider.akamai import geo_zone_code_mapping
from poppy.provider import base
LOG = log.getLogger(__name__)
@ -557,7 +558,7 @@ class ServiceController(base.ServiceBase):
# for each restriction rule
# restriction entities include: referrer, geography, client_ip
restriction_entities = ['referrer', 'client_ip']
restriction_entities = ['referrer', 'geography', 'client_ip']
class entityRequestUrlMappingList(dict):
"""A dictionary with a name attribute"""
@ -599,6 +600,14 @@ class ServiceController(base.ServiceBase):
else:
entity_rule_mapping['client_ip'][rule_entry.request_url]\
.append(rule_entry)
elif getattr(rule_entry, "geography", None) is not None:
if (rule_entry.request_url not in
entity_rule_mapping['geography']):
entity_rule_mapping['geography'][rule_entry.request_url]\
= [rule_entry]
else:
entity_rule_mapping['geography'][rule_entry.request_url]\
.append(rule_entry)
for entity_request_url_rule_mapping in [white_list_entities,
black_list_entities]:
@ -618,6 +627,9 @@ class ServiceController(base.ServiceBase):
'value': behavior_value
}
if entity == 'geography':
behavior_dict['type'] = 'country'
# if we have a matches rule already
for rule in rules_list:
for match in rule['matches']:
@ -665,7 +677,7 @@ class ServiceController(base.ServiceBase):
'type': 'natural',
'value': 'now',
})
# if there is no matches entry yet for this rule
# if there is no matches entry yet for this rule
if not found_match:
# create an akamai rule
rule_dict_template = {
@ -691,6 +703,8 @@ class ServiceController(base.ServiceBase):
prefix = 'referer'
elif entity == 'client_ip':
prefix = 'ip'
elif entity == 'geography':
prefix = 'geo'
if entity_restriction_access == 'whitelist':
suffix = 'whitelist'
@ -714,6 +728,20 @@ class ServiceController(base.ServiceBase):
for rule_entry
in rule_entries
])
elif entity == 'geography':
# We ignore the country that Akamai doesn't support for right now
zones_list = []
for rule_entry in rule_entries:
if rule_entry.geography in (
geo_zone_code_mapping.REGION_COUNTRY_MAPPING):
zones_list.extend(
geo_zone_code_mapping.REGION_COUNTRY_MAPPING[
rule_entry.geography])
else:
zones_list.append(rule_entry.geography)
return ' '.join(
['%s' % geo_zone_code_mapping.COUNTRY_CODE_MAPPING.get(
zone, '') for zone in zones_list])
def _process_caching_rules(self, caching_rules, rules_list):
# akamai requires all caching rules to start with '/'

View File

@ -646,7 +646,6 @@ class ServicesController(base.ServicesController):
restrictions = [restriction.Restriction(
r.get('name'),
r.get('access'),
[rule.Rule(r_rule.get('name'),
referrer=r_rule.get('referrer'),
client_ip=r_rule.get('client_ip'),

View File

@ -574,5 +574,209 @@
"hostheadervalue": "www.customweb.com"
}],
"caching_list": []
}
},
"geo_restriction": {
"name": "my_service_name",
"domain_list": [{"domain": "www.mywebsite.com", "protocol": "http"},
{"domain": "blog.mywebsite.com", "protocol": "http"}],
"origin_list": [{
"origin": "myorigin.com",
"port": 80,
"ssl": false,
"rules": [
{
"name" : "default",
"request_url" : "/*"
}]
}],
"caching_list": [
{
"name": "default",
"ttl": 3600,
"rules": [
{
"name" : "default",
"request_url" : "/*"
}
]
},
{
"name": "home",
"ttl": 1200,
"rules": [
{
"name" : "index",
"request_url" : "/index.htm"
}
]
}
],
"restrictions_list": [
{
"name": "test",
"access": "whitelist",
"rules": [
{
"name": "only USA",
"geography": "USA",
"request_url" : "/*"
}
]}
]
},
"geo_region_restriction": {
"name": "my_service_name",
"domain_list": [{"domain": "www.mywebsite.com", "protocol": "http"},
{"domain": "blog.mywebsite.com", "protocol": "http"}],
"origin_list": [{
"origin": "myorigin.com",
"port": 80,
"ssl": false,
"rules": [
{
"name" : "default",
"request_url" : "/*"
}]
}],
"caching_list": [
{
"name": "default",
"ttl": 3600,
"rules": [
{
"name" : "default",
"request_url" : "/*"
}
]
},
{
"name": "home",
"ttl": 1200,
"rules": [
{
"name" : "index",
"request_url" : "/index.htm"
}
]
}
],
"restrictions_list": [
{
"name": "test",
"access": "whitelist",
"rules": [
{
"name": "only North America",
"geography": "North America",
"request_url" : "/*"
}
]}
]
},
"geo_restriction_blacklist": {
"name": "my_service_name",
"domain_list": [{"domain": "www.mywebsite.com", "protocol": "http"},
{"domain": "blog.mywebsite.com", "protocol": "http"}],
"origin_list": [{
"origin": "myorigin.com",
"port": 80,
"ssl": false,
"rules": [
{
"name" : "default",
"request_url" : "/*"
}]
}],
"caching_list": [
{
"name": "default",
"ttl": 3600,
"rules": [
{
"name" : "default",
"request_url" : "/*"
}
]
},
{
"name": "home",
"ttl": 1200,
"rules": [
{
"name" : "index",
"request_url" : "/index.htm"
}
]
}
],
"restrictions_list": [
{
"name": "test",
"access": "blacklist",
"rules": [
{
"name": "only not in Mexico",
"geography": "Mexico",
"request_url" : "/*"
}
]}
]
},
"all_types_of_restrictions": {
"name": "my_service_name",
"domain_list": [{"domain": "www.mywebsite.com", "protocol": "http"},
{"domain": "blog.mywebsite.com", "protocol": "http"}],
"origin_list": [{
"origin": "myorigin.com",
"port": 80,
"ssl": false,
"rules": [
{
"name" : "default",
"request_url" : "/*"
}]
}],
"caching_list": [
{
"name": "default",
"ttl": 3600,
"rules": [
{
"name" : "default",
"request_url" : "/*"
}
]
},
{
"name": "home",
"ttl": 1200,
"rules": [
{
"name" : "index",
"request_url" : "/index.htm"
}
]
}
],
"restrictions_list": [
{
"name": "test",
"access": "whitelist",
"rules": [
{
"name": "only in US",
"geography": "USA",
"request_url" : "/*"
},{
"name": "only from my site",
"referrer": "www.mywebsite.com",
"request_url" : "/*"
},{
"name": "only from 1111",
"client_ip": "1.1.1.1",
"request_url" : "/*"
}
]}
]
}
}

View File

@ -903,5 +903,28 @@
"rules": [{"name" : "index",
"request_url" : "/index.htm"}]}],
"restrictions_list": []
},
"invalid_country_code_geo_restriction": {
"service_name": "invalid_country_level_root_domain2",
"domain_list": [{"domain": "mywebsite.co.au"},
{"domain": "blog.mywebsite.com"}],
"origin_list": [{"origin": "myorigin.com",
"port": 443,
"ssl": false}],
"caching_list": [{"name": "default", "ttl": 3600},
{"name": "home",
"ttl": 1200,
"rules": [{"name" : "index",
"request_url" : "/index.htm"}]}],
"restrictions_list": [{
"name": "test",
"access": "whitelist",
"rules": [
{
"name": "only in US",
"geography": "US",
"request_url" : "/*"
}
]}]
}
}

View File

@ -357,5 +357,44 @@
,{"name": "myrestricted-ip-2",
"client_ip": "5.6.7.8",
"request_url": "/*"}]}}
],
"replace_add_geo_restriction":[
{"op": "replace",
"path": "/restrictions/0",
"value": {"name": "website only",
"access": "whitelist",
"rules": [{"name": "mywebsite.com",
"referrer": "www.mywebsite.com",
"request_url": "/*"
}, {"name": "myrestricted-geo",
"geography": "USA",
"request_url": "/*"}
]}}
],
"replace_add_geo_restriction_multiple_country":[
{"op": "replace",
"path": "/restrictions/0",
"value": {"name": "website only",
"access": "whitelist",
"rules": [{"name": "mywebsite.com",
"referrer": "www.mywebsite.com",
"request_url": "/*"
}, {"name": "myrestricted-geo",
"geography": "USA",
"request_url": "/*"
}, {"name": "myrestricted-geo",
"geography": "Mexico",
"request_url": "/*"}
]}}
],
"replace_add_blacklist_geo_restriction":[
{"op": "replace",
"path": "/restrictions/0",
"value": {"name": "website only",
"access": "blacklist",
"rules": [{"name": "myrestricted-geo",
"geography": "USA",
"request_url": "/*"}
]}}
]
}

View File

@ -204,6 +204,30 @@
"value": {"domain": "replaceme.com", "protocol": "https",
"certificate": "shared"}}
],
"add_restrictions_with_invalid_country_region_code": [
{"op": "add",
"path": "/restrictions/-",
"value": {"name": "restricted-nonsense-country",
"rules": [{"name": "rule1", "geography": "NOTACOUNTRY"}]
}
}
],
"add_restrictions_with_conflict_blacklist_geo": [
{"op": "add",
"path": "/restrictions/-",
"value": {"name": "restricted-nonsense-country",
"access": "whitelist",
"rules": [{"name": "rule1", "geography": "USA"}]
}
},
{"op": "add",
"path": "/restrictions/-",
"value": {"name": "restricted-nonsense-country",
"access": "blacklist",
"rules": [{"name": "rule1", "geography": "Mexico"}]
}
}
],
"add_restrictions_with_invalid_ip": [
{"op": "add",
"path": "/restrictions/-",