Code Monkey home page Code Monkey logo

kong-plugin-referer's Introduction

Referer verification plugin

Easily add referer access to your API by enabling this plugin.

NOTE: This is not a secure plugin! it is based on the referer header that anyone could spoof. For security consider real authentication plugins.


Installation

Install the rock when building your Kong image/instance:

luarocks install kong-plugin-referer

Add the plugin to your custom_plugins section in kong.conf, the KONG_CUSTOM_PLUGINS is also available.

custom_plugins = referer

Compatibility

Plugin Kong version
v1.1-1 < 1.x.x
v2.0-0 >= 2.0.x

Configuration

Configuring the plugin is as simple as a single API call, you can configure and enable it for your API by executing the following request on your Kong server:

$ curl -X POST http://kong:8001/apis/{api}/plugins \
    --data "name=referer" \
    --data "config.referers=mockbin.com, *.mockbin.com" \

api: The id or name of the API that this plugin configuration will target

You can also apply it for every API using the http://kong:8001/plugins/ endpoint. Read the Plugin Reference for more information.

form parameter default description
name Name of the plugin to use, in this case: referer
config.referers A comma-separated list of allowed domains for the referer header. If you wish to allow all referer, add * as a single value to this configuration field.

Testing

The code can be tested using the kong-vagrant environment.

# clone the repositories
git clone http://github.com/kong/kong-vagrant.git
cd kong-vagrant
git clone http://github.com/kong/kong.git
git clone http://github.com/eyolas/kong-plugin-referer.git

# checkout the required Kong version
export TEST_VERSION=2.0.2
pushd kong; git checkout $(TEST_VERSION); popd

# Build vagrant with same Kong version and the plugin
KONG_VERSION=$(TEST_VERSION) KONG_PLUGIN_PATH=./kong-plugin-referer vagrant up
vagrant ssh

# Build dev environment
cd /kong
make dev

# Execute tests
bin/busted -v -o gtest /kong-plugin/spec

kong-plugin-referer's People

Contributors

eyolas avatar tieske avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

kong-plugin-referer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.