GithubHelp home page GithubHelp logo

devenfan / kong-java-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vaibhav-sinha/kong-java-client

0.0 2.0 0.0 127 KB

Java Client for Kong API Gateway configuration

License: Apache License 2.0

Java 100.00%

kong-java-client's Introduction

Kong Java Client

Kong is a popular Open Source API Gateway. Kong Java Client makes it easy to configure the API Gateway through your code.

Installation

The artifact is available on Maven Central Repository and be downloaded by adding the following dependency in pom.xml

<dependency>
    <groupId>com.github.vaibhav-sinha</groupId>
    <artifactId>kong-java-client</artifactId>
    <version>0.1.2-SNAPSHOT</version>
</dependency>

Usage

KongClient kongClient = new KongClient("http://localhost:8001");
Consumer request = new Consumer();
request.setCustomId("1234-5678-9012");
Consumer response = kongClient.getConsumerService().createConsumer(request);

Look in the tests to find more examples.

Supported Plugins

Besides the Admin APIs, Plugin configuration is also supported.

Authentication Plugins

  • Basic Auth
  • Key Auth
  • HMAC Auth
  • JWT Auth
  • OAuth2
  • LDAP

Security Plugins

  • ACL
  • IP Restriction

Traffic Control Plugins

  • Rate Limiting
  • Request Size Limiting
  • Request Termination

Only those plugins are supported which might need configuration through code. For example, adding rate limit for a new consumer when there is a new signup. Plugins which require one time configuration are not supported.

Example Usage

To add credentials for a new Consumer for Basic Auth

kongClient.getBasicAuthService().addCredentials("con-su-mer-id", "username", "password");

To add OAuth2 Plugin for an API

//See: RetrofitApiPluginServiceTest.java
kongClient.getApiPluginService().addPluginForApi(API_NAME, oauth2Plugin);

To add an Application for a Consumer for OAuth2

//See: RetrofitOAuth2ManageServiceTest.java
kongClient.getOAuth2ManageService().createConsumerApplication(CONSUMER_ID, 
    new Application(appName, appRedirectUrl, appClientId, appClientSecret));

To do the OAuth2 Process (Authorization Code)

//See: RetrofitOAuth2ProcessServiceTest.java
kongClient.getOAuth2ProcessService().authorize(API_URI, authorizationRequest);
kongClient.getOAuth2ProcessService().grantToken(API_URI, grantTokenRequest)

kong-java-client's People

Contributors

vaibhav-sinha avatar devenfan avatar dvilela avatar kgignatyev-inspur avatar

Watchers

James Cloos avatar  avatar

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.