HTTP 403 Forbidden
.
Note that this is not the same as Tyk’s IP block list feature, which is used to restrict access to APIs based upon the IP of the requestor.
HTTP 403 Forbidden
.
GET /userID
in your API definition then only calls to GET /userID
will be blocked: calls to GET /UserID
or GET /userid
will be allowed. You can configure the middleware to be case-insensitive at the endpoint level.
You can also set case sensitivity for the entire gateway in the Gateway configuration file tyk.conf
. If case insensitivity is configured at the gateway level, this will override the endpoint-level setting.
HTTP 403 Forbidden
.
When working with Tyk OAS APIs the middleware is configured in the Tyk OAS API Definition. You can do this via the Tyk Dashboard API or in the API Designer.
If you’re using the legacy Tyk Classic APIs, then check out the Tyk Classic page.
operationId
defined in the OpenAPI Document that declares both the path and method for which the middleware should be added. The path
can contain wildcards in the form of any string bracketed by curly braces, for example {user_id}
. These wildcards are so they are human readable and do not translate to variable names. Under the hood, a wildcard translates to the “match everything” regex of: (.*)
.
The block list middleware (block
) can be added to the operations
section of the Tyk OAS Extension (x-tyk-api-gateway
) in your Tyk OAS API Definition for the appropriate operationId
(as configured in the paths
section of your OpenAPI Document).
The block
object has the following configuration:
enabled
: enable the middleware for the endpointignoreCase
: if set to true
then the path matching will be case insensitiveGET /anything
and PUT /anything
endpoints. Requests to these endpoints will be rejected with HTTP 403 Forbidden
.
Note that the block list has been configured to be case insensitive, so calls to GET /Anything
will also be blocked.
Note also that the endpoint path has not been terminated with $
. Requests to, for example, GET /anything/foobar
will be rejected as the regular expression pattern match will recognize this as GET /anything
.
The configuration above is a complete and valid Tyk OAS API Definition that you can import into Tyk to try out the block list feature.
HTTP 403 Forbidden
.
When working with Tyk Classic APIs the middleware is configured in the Tyk Classic API Definition. You can do this via the Tyk Dashboard API or in the API Designer.
If you’re using the newer Tyk OAS APIs, then check out the Tyk OAS page.
If you’re using Tyk Operator then check out the configuring the block list in Tyk Operator section below.
black_list
object to the extended_paths
section of your API definition.
black_list
object has the following configuration:
path
: the endpoint pathmethod
: this should be blankignore_case
: if set to true
then the path matching will be case insensitivemethod_actions
: a shared object used to configure the mock response middlewaremethod_actions
object should be configured as follows, with an entry created for each blocked method on the path:
action
: this should be set to no_action
code
: this should be set to 200
headers
: this should be blankGET
and PUT
requests to the /status/200
endpoint. Requests to these endpoints will be rejected with HTTP 403 Forbidden
.
Note that the block list has been configured to be case sensitive, so calls to GET /Status/200
will not be rejected.
Note also that the endpoint path has not been terminated with $
. Requests to, for example, GET /status/200/foobar
will be rejected as the regular expression pattern match will recognize this as GET /status/200
.
Consult section configuring the Allow List in Tyk Operator for details on how to configure allow lists for endpoints using Tyk Operator.
black_list
object to the extended_paths
section of your API definition. Furthermore, the use_extended_paths
configuration parameter should be set to true
.
GET
requests to the /get
endpoint. Requests to this endpoint will be rejected with HTTP 403 Forbidden
.
Note that the block list has been configured to be case insensitive, so calls to GET /Get
will not be rejected.
Note also that the endpoint path has not been terminated with $
. Requests to, for example, GET /get/foobar
will be rejected as the regular expression pattern match will recognize this as GET /get
.