Using ignored, white_list and black_list


#1

I’m pretty making a mess to understand the usage of ignored, white_list and black_list.
I’m following the tutorials, but when I code:

[
  {
    "path": "/get",
    "method_actions": {
      "GET": {
         "action": "no_action",
          "code": 200,
          "data": "Hello World!\n",
          "headers": {
            "blabla": "hi",
          }
       }
    }
  }
]

is it in the ignored field or while list or black list field, everytime I make a call all I get is a 404 page not found.
I tried to change the action in reply, but I always get the same thing.


Extended_paths -> ignore list & white list issue
#2

You’ll need to use the extended paths section

What are you trying to achieve? If you want to mock out responses you will need to do this:

...
"ignored": [
    {
        "path": "/v1/ignored/with_id/{id}",
        "method_actions": {
            "GET": {
                "action": "reply",
                "code": 200,
                "data": "Hello World\n",
                "headers": {
                    "x-tyk-override": "tyk-override",
                }
            }
        }
    }
],
...

#3

What I’m trying to achieve is to understand what ignored, white_list and black_list fields do. First of all let me say that I’ve set use_extended_paths: true.
Now I’ll try to explain what I understood so far, in this way you can point me out where I’m mistaking.
About ignored, as the doc says:

This section will define methods and paths that will be ignored and will bypass the quota and rate limiting machinery of Tyk.

If I code:

"ignored": [
    {
        "path": "/v1/ignored/with_id/{id}",
        "method_actions": {
            "GET": {
                "action": "reply",
                "code": 200,
                "data": "Hello World\n",
                "headers": {
                    "x-tyk-override": "tyk-override",
                }
            }
        }
    }
],

and I have a "listen_path"="/test-api/" and "target_url"="http://httpbin.org/", if the user calls GET http://localhost:8080/test-api/v1/ignored/with_id/{id} he will receive an HTTP response with code 200 body “hello world” and the set headers.


#4

yup, except you probably don’t need the initial slash on "path": "/v1/ignored/with_id/{id}", because it’s part of the listen path and will be stripped, so your path should be:

"path": "v1/ignored/with_id/{id}"

As for the three lists:

  • Ignored: Bypasses all auth, great for logins or heartbeat calls
  • Blacklist - Access is blocked to these paths, e.g. you v1 and v2 of an API and in v2, the resource /widget/ is deprecated, so you in the v2 blacklist settings you explicitly set this path as a blacklist so that v2 users get an error to not use that path
  • Whitelist: An exclusive list of paths and patterns that are allowed, adding one element to a white list automatically (obviously) blacklists everything else.

#5

I found the error…it was the comma in "blabla": "hi",


#6

I’ll just leave this here :wink: