Blacklists¶
Overview¶
The blacklist entries are used to manage blacklisted zones. If a zone is blacklisted, then it cannot be used to create a zone. By default, only an admin can manage these entries. Blacklisted zones are stored as a regular expression (regex) pattern in the Database/Storage in the blacklists table.
Blacklist Checks¶
Every time a new zone is created, that domain name is checked against the blacklisted zones in the database. If it matches the regex pattern, then a 400 is returned with the message “Blacklisted domain name”. If there is no match, then the zone is created. When a new blacklisted pattern is added, it will catch any matching new zones, but it does not check for existing zones that match the blacklisted pattern.
Regular Expressions¶
Any valid regular expression may be added to the blacklists table. Here are some examples:
^example\\.com\\.$
This will block the “example.com.” domain, but will not block any sub-domains, e.g. “my.example.com.” or anything else containing example.com, such as, “myexample.com.”
^([A-Za-z0-9_\-]+\\.)*example\\.com\\.$
This will block “example.com.” and all sub-domains, e.g. “my.example.com.”, but anything else containing example.com, will not be blocked, such as, “myexample.com.”
NOTE: When using regular expressions in json, the ‘\’ character needs to be escaped with an additional ‘\’, so it needs to be written as “^example\\.com\\.$”
Create a Blacklist¶
-
POST
/blacklists
¶ Create a blacklist. pattern is the only entry that is required. The domain name part of the pattern should end in a period (.).’
Example request:
POST /blacklists HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json { "pattern" : "^([A-Za-z0-9_\\-]+\\.)*example\\.com\\.$", "description" : "This is a blacklisted domain." }
Example response:
HTTP/1.1 201 Created Content-Type: application/json; charset=UTF-8 Location: 127.0.0.1:9001/v2/blacklists/c47229fb-0831-4b55-a5b5-380d361be4bd { "description":"This is a blacklisted domain.", "links":{ "self":"http://127.0.0.1:9001/v2/blacklists/c47229fb-0831-4b55-a5b5-380d361be4bd" }, "pattern":"^([A-Za-z0-9_\\-]+\\.)*example\\.com\\.$", "created_at":"2014-03-11T21:54:57.000000", "updated_at":null, "id":"c47229fb-0831-4b55-a5b5-380d361be4bd" }
Form Parameters: - created_at – timestamp
- updated_at – timestamp
- pattern – blacklist regular expression
- id – uuid
- description – UTF-8 text field
- links – links to traverse the list
Status Codes: - 201 Created – Created
- 401 Unauthorized – Access Denied
- 400 Bad Request – Invalid Object
- 409 Conflict – Duplicate Blacklist
Get a Blacklist¶
-
GET
/blacklists/
(uuid: id)¶ Lists a particular Blacklisted domain
Example request:
GET /blacklists/c47229fb-0831-4b55-a5b5-380d361be4bd HTTP/1.1 Host: example.com Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 { "description":"This is a blacklisted domain.", "links":{ "self":"http://127.0.0.1:9001/v2/blacklists/c47229fb-0831-4b55-a5b5-380d361be4bd" }, "pattern":"^([A-Za-z0-9_\\-]+\\.)*example\\.com\\.$", "created_at":"2014-03-11T21:54:57.000000", "updated_at":null, "id":"c47229fb-0831-4b55-a5b5-380d361be4bd" }
Form Parameters: - created_at – timestamp
- updated_at – timestamp
- pattern – blacklist regular expression
- id – uuid
- description – UTF-8 text field
- links – links to traverse the list
Status Codes: - 200 OK – OK
- 401 Unauthorized – Access Denied
- 404 Not Found – Blacklist not found
List Blacklists¶
-
GET
/blacklists
¶ Lists all blacklists
Example request:
GET /blacklists HTTP/1.1 Host: example.com Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 { "blacklists":[ { "description": "This is a blacklisted domain.", "links":{ "self":"http://127.0.0.1:9001/v2/blacklists/c47229fb-0831-4b55-a5b5-380d361be4bd" }, "pattern":"^([A-Za-z0-9_\\-]+\\.)*example\\.com\\.$", "created_at":"2014-03-11T21:54:57.000000", "updated_at":null, "id":"c47229fb-0831-4b55-a5b5-380d361be4bd" }, { "description": null, "links":{ "self":"http://127.0.0.1:9001/v2/blacklists/61140aff-e2c8-488b-9bf4-da710ec8732b" }, "pattern" : "^examples\\.com\\.$", "created_at":"2014-03-07T21:05:59.000000", "updated_at":null, "id":"61140aff-e2c8-488b-9bf4-da710ec8732b" } ], "links":{ "self":"http://127.0.0.1:9001/v2/blacklists" } }
Form Parameters: - created_at – timestamp
- updated_at – timestamp
- pattern – blacklist regular expression
- id – uuid
- description – UTF-8 text field
- links – links to traverse the list
Status Codes: - 200 OK – OK
- 401 Unauthorized – Access Denied
Update a Blacklist¶
-
PATCH
/blacklists/
(uuid: id)¶ updates a blacklist
Example request:
PATCH blacklists/c47229fb-0831-4b55-a5b5-380d361be4bd HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json { "pattern" : "^([A-Za-z0-9_\\-]+\\.)*example\\.com\\.$", "description" : "Updated the description" }
Example response:
HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 { "description":"Updated the pattern to catch subdomains", "links":{ "self":"http://127.0.0.1:9001/v2/blacklists/c47229fb-0831-4b55-a5b5-380d361be4bd" }, "created_at":"2014-03-11T21:54:57.000000", "updated_at":"2014-03-13T16:49:32.117187", "id":"c47229fb-0831-4b55-a5b5-380d361be4bd", "pattern":"^([A-Za-z0-9_\\-]+\\.)*example\\.com\\.$" }
Form Parameters: - created_at – timestamp
- updated_at – timestamp
- pattern – blacklist regular expression pattern
- id – uuid
- description – UTF-8 text field
- links – links to traverse the list
Status Codes: - 200 OK – OK
- 401 Unauthorized – Access Denied
- 404 Not Found – Blacklist not found
- 409 Conflict – Duplicate Blacklist
Delete a Blacklist¶
-
DELETE
/blacklists/
(uuid: id)¶ delete a blacklist
Example request:
DELETE /blacklists/c47229fb-0831-4b55-a5b5-380d361be4bd HTTP/1.1 Host: example.com
Example response:
HTTP/1.1 204 No Content Content-Type: application/json; charset=UTF-8 Content-Length: 0
Status Codes: - 204 No Content – No Content
- 401 Unauthorized – Access Denied
- 404 Not Found – Blacklist not found