Open (Keyless)
.Authorization
.Meta
field - you will need it later as this is the Tyk Gateway’s internal identifier for the new API.
/httpbin
. Using this path-based-routing, the gateway was able to identify the API the client intended to target.
The gateway stripped the listen path and reverse proxied the request to http://httpbin.org/get
api.httpbin.json
file we just created, and modify a couple of fields to enable authentication.
Change use_keyless
from true
to false
.
Change auth_configs.authToken.auth_header_name
to apikey
.
Note Prior to ** Tyk v2.9.2** auth_configs.authToken.auth_header_name
was called auth.auth_header_name
Then send a PUT
request back to Tyk Dashboard to update its configuration.
HTTP 401 Unauthorized
response.
Now send a request with incorrect credentials:
HTTP 403 Forbidden
response.
Try sending another request, this time with a valid API key.
Congratulations - You have just created your first keyless API, then protected it using Tyk!
/apis
endpoint. See API definition objects for details of all the available objects. These objects encapsulate all of the settings for an API within Tyk.
Want to learn more from one of our team of engineers?
Book a demo
tyk.conf
file; the property is called secret
. You will need to provide this value in a header called x-tyk-authorization
when making calls to the Gateway API.
/apis
endpoint on your Tyk Gateway. Remember to change the x-tyk-authorization
value (API key) in the header of your API call and set the domain name and port to target your Tyk Gateway in the curl
command.
API ID
; if you don’t provide one in the Tyk API Definition when creating the API, then an API ID
will be generated automatically./apis
endpoint./hello-world/
.
api1.json
and place it in the /apps
folder of your Tyk Gateway installation (usually in /var/tyk-gateway
), then add the following:
/test-api/
.
Your API is now ready to use via the Gateway.
{API-TOKEN}
: Your API Token for the Dashboard API.{API-ID}
: The API ID you wish this policy to grant access to, there can be more than one of these entries.{API-NAME}
: The name of the API that is being granted access to (this is not required, but helps when debugging or auditing).POLICY NAME
: The name of this security policy.access_rights
: A list of objects representing which APIs that you have configured to grant access to.
rate
and per
: The number of requests to allow per period.
quota_max
: The maximum number of allowed requests over a quota period.
quota_renewal_rate
: how often the quota resets, in seconds. In this case we have set it to renew every hour.
state
: New from v3.0, this can be used instead of active
and is_inactive
. You can use the following values:
active
- all keys connected to the policy are active and new keys can be createddraft
- all keys connected to the policy are active but new keys cannot be createddeny
- all keys are deactivated and no keys can be created.state
value will automatically override the active
or is_inactive
setting.apply_policy_id
field of an API token. Please see the relevant documentation on session objects for more information about how tokens are attached to policies.
apply_policy_id
is supported, but has now been deprecated. apply_policies
is now used to list your policy IDs as an array. This supports the Multiple Policy feature introduced in the v2.4/1.4 release.{API-TOKEN}
: Your API Token for the Dashboard API.{API-ID}
: The API ID you wish this policy to grant access to, there can be more than one of these entries.{API-NAME}
: The name of the API that is being granted access to (this is not required, but helps when debugging or auditing).POLICY NAME
: The name of this security policy.access_rights
: A list of objects representing which APIs that you have configured to grant access to.
rate
and per
: The number of requests to allow per period.
quota_max
: The maximum number of allowed requests over a quota period.
quota_renewal_rate
: how often the quota resets, in seconds. In this case we have set it to renew every hour.
state
: New from v3.0, this can be used instead of active
and is_inactive
. You can use the following values:
active
- all keys connected to the policy are active and new keys can be createddraft
- all keys connected to the policy are active but new keys cannot be createddeny
- all keys are deactivated and no keys can be created.state
value will automatically override the active
or is_inactive
setting.apply_policy_id
field of an API token. Please see the relevant documentation on session objects for more information about how tokens are attached to policies.
apply_policy_id
is supported, but has now been deprecated. apply_policies
is now used to list your policy IDs as an array. This supports the Multiple Policy feature introduced in the v2.4/1.4 release.policies.json
. To add a policy, simply create or edit the /policies/policies.json
file and add the policy object to the object array:
access_rights
section.
{API-ID}
: The API ID you wish this policy to grant access to, there can be more than one of these entries.{API-NAME}
: The name of the API that is being granted access to (this is not required, but helps when debugging or auditing).POLICY NAME
: The name of this security policy.access_rights
: A list of objects representing which APIs that you have configured to grant access to.rate
and per
: The number of requests to allow per period.quota_max
: The maximum number of allowed requests over a quota period.quota_renewal_rate
: how often the quota resets, in seconds. In this case we have set it to renew every hour.curl
command will generate a key for one of your APIs:
authorization
header value with your Tyk Dashboard API Access Credentialsad5004d961a147d4649fd3216694ebe2
) with your API IDmalformed input
errorkey_id
parameter of the response is the access key you can now use to access the API that was specified in the access_rights
section of the call.
curl
command will generate a key for one of your APIs:
authorization
header value with your Tyk Dashboard API Access Credentialsad5004d961a147d4649fd3216694ebe2
) with your API IDmalformed input
errorkey
parameter of the response is the access key you can now use to access the API that was specified in the access_rights
section of the call.
secret
property of the tyk.conf
file.curl
command will generate a key for one of your APIs, remember to replace {API-SECRET}
, {API-ID}
and {API-NAME}
with the real values as well as the curl
domain name and port to be the correct values for your environment.
access_rights
section.
{API-ID}
: The API ID you wish this policy to grant access to, there can be more than one of these entries.{API-NAME}
: The name of the API being granted access to (this is not required, but helps when debugging or auditing).access_rights
: A list of objects representing which APIs you have configured to grant access to.rate
and per
: The number of allowed requests per period.quota_max
: The maximum number of allowed requests over a quota period.quota_renewal_rate
: how often the quota resets, in seconds. In this case, we have set it to renew every hour.key
parameter of the response is the access key you can now use to access the API that was specified in the access_rights
section of the call.
stdout
. Below are the commands you can use to get Tyk to switch to command mode and generate the respective API definitions for both API Blueprint and Swagger files.
stdout
, so redirecting the output to a file is advised in order to generate new definitions to use in a real configuration.
--as-mock
parameter.
use_extended_paths
setup, adding mocked URL data to one of the three list types (white_list, black_list or ignored). In order to handle a mocked path, use an entry that has action
set to reply
:
Property | Description |
---|---|
Resource URL | /api/import/swagger/ |
Method | POST |
Type | None |
Body | None |
Param | None |
insert_into_api
: If set to true
the import will replace an existing API. Setting to false
will import into a new API.api_id
: The internal MongoDB object id for your API.version_name
: Your versioning convention name for the imported API.upstream_url
: The URL the API is served by.Property | Description |
---|---|
Resource URL | /api/import/blueprint/ |
Method | POST |
Type | None |
Body | None |
Param | None |
insert_into_api
: If set to true
the import will replace an existing API. Setting to false
will import into a new API.api_id
: The internal MongoDB object id for your API.as_mock
: If set to true, enables our mocking support for Blueprint imported API. See Mocks above for more details.version_name
: Your versioning convention name for the imported API.upstream_url
: The URL the API is served by.