Skip to content

Instantly share code, notes, and snippets.

@letzya
letzya / test-virtual-endpoint.json
Last active September 25, 2022 08:54
test-virtual-endpoint
{
"id": "XXXXb1957251bab02553XXXX",
"name": "Test virtualEndpoint 2",
"slug": "testvirtual",
"api_id": "XXXX796c5de45e649f22da390d7XXXX",
"org_id": "XXXXd3a0de0dc60001ffXXXX",
"use_keyless": true,
"use_oauth2": false,
"use_openid": false,
"openid_options": {
@letzya
letzya / test-virtual-endpoint-README.md
Last active July 27, 2018 14:00
Virtual Endpoint Example

Demo for Virtual Endpoints

This demo requires an on-premises installation of tyk-pro

You can quickly import the API definition TykDefidefinitionVirtualEndpoint.json into dashboard as a new api and test it with the following api call:

curl --url 'http://tyk-gateway:8080/testvirtualendpoint2/headers?param1=I-am-param-1' --header 'location: /get' -v or you can set it up your self by following the instruction bellow:

Setting up virtual endpoint

@letzya
letzya / BodyTransportXML-To-JSON-petstore.txt
Last active September 17, 2018 12:41
Demo body transform of response, XML to JSON using petstore's endpoint /pet/{id}
1. Import to Tyk swagger petstore as an api.
2. In the endpoint designer, under endpoint /pet/{id} add the `body transform plugin
3. Click on respose
4. Paste this template
{
"category": {
"id": {{.Pet.category.id}},
"name": "{{.Pet.category.name}}"
},
"id": {{.Pet.id}},
@letzya
letzya / BodyTransportXML-To-JSON-petstore-APIDefinition.json
Created September 17, 2018 12:42
Tyk Api definition for BodyTransportXML-To-JSON-petstore.txt
{
"id": "5b9f7af01706240001514239",
"name": "Swagger Petstore #demo",
"slug": "v2",
"api_id": "2f0a9c3265d34f06519b68a5e4737087",
"org_id": "5b3e218792306d000140a992",
"use_keyless": true,
"use_oauth2": false,
"use_openid": false,
"openid_options": {
@letzya
letzya / auth0OAuthClientCredVirtualHandler.js
Created December 17, 2018 18:12
This demo how Tyk can do the flow of a client in OAuth2.0 Client_credentials flow. Tyk requests for an access_token which later is forwareded to the backend service (in this case, it's a local httpbin service) and then returns to the user the header it had sent to httpbin, i.e. the value of Authorization header as a proof that the backend had re…
function auth0OAuthClientCredVirtualHandler (request, session, config) {
log("request object: " + JSON.stringify(request))
log("---")
//Make api call to upstream target
oauthClientRequest = {
"Method": "POST",
"Body": "{\"client_id\":\"{PASTE-YOUR-OWN-CLIEND-ID}\",\"client_secret\":\"{PASTE-YOUR-OWN-CLIEND-SECRET}\",\"audience\":\"auth0-id\",\"grant_type\":\"client_credentials\"}",
"Headers": {"content-type":"application/json"},
@letzya
letzya / azureOauthClientCredVirtualHandler.js
Last active December 17, 2018 18:35
This demo how Tyk can do the flow of a client in OAuth2.0 Client_credentials flow. Tyk requests for an access_token which later is forwareded to the backend service (in this case, it's a local httpbin service) and then returns to the user the header it had sent to httpbin, i.e. the value of Authorization header as a proof.
function azureOauthClientCredVirtualHandler (request, session, config) {
log("request object: " + JSON.stringify(request))
log("---")
//Make api call to upstream target
//In Azure AD APPLICATION ID is the client id
oauthClientRequest = {
"Method": "POST",
"Body": "client_id={YOUR-OWN-CLIENT-ID}&client_secret={YOUR-OWN-CLIENT-SECRET}&grant_type=client_credentials&resource=https%3A%2F%2F{YOUR-OWN-ORG-NAME}.onmicrosoft.com%2F{ID}",
@letzya
letzya / catalogue.html
Last active June 15, 2020 17:39
Catalogue which doesn't display internal apis to external developers or non logged in viewers
{{ define "cataloguePage" }} {{ $org_id := .OrgId}} {{ template "header" .}}
{{ $page := .}}
<body>
{{ template "navigation" . }}
<div>
<!-- Main content here -->
@letzya
letzya / httpbin-swagger.json
Created March 10, 2020 19:43
Swagger for httpbin.org for host "www.tyk-test.com:8080" and api name "httpbin" and no version
{
"swagger": "2.0",
"info": {
"version": "",
"title": "httpbin",
"description": "http request and response services"
},
"host":"www.tyk-test.com:8080",
"basePath":"/httpbin",
"paths": {
@letzya
letzya / TykDefinitionJwt.json
Created April 30, 2020 18:54
TykDefinitionJwt - Api definition with "pol" claim and no default policy or scopes. Shared secret test123
{
"id": "5ea0447410d1660001fe3f2e",
"name": "jwt - bruno",
"slug": "jwt-bruno",
"listen_port": 0,
"protocol": "",
"enable_proxy_protocol": false,
"api_id": "2be5aaa57e7a422f7c7d7fd9a65e2c49",
"org_id": "5e1e38108cf2410001c8a972",
"use_keyless": false,
@letzya
letzya / TykDefinitionJwt.json
Created April 30, 2020 18:58
Policies (with one policy called policy-jwt) and Tyk API Definition (with "pol" claim and no default policy or scopes. Shared secret test123)
{
"id": "5ea0447410d1660001fe3f2e",
"name": "jwt - bruno",
"slug": "jwt-bruno",
"listen_port": 0,
"protocol": "",
"enable_proxy_protocol": false,
"api_id": "2be5aaa57e7a422f7c7d7fd9a65e2c49",
"org_id": "5e1e38108cf2410001c8a972",
"use_keyless": false,