https://github.com/vaibhav-sinha/kong-java-client
Java Client for Kong API Gateway configuration
https://github.com/vaibhav-sinha/kong-java-client
api-gateway client-library java java-client kong kong-java-client
Last synced: about 1 month ago
JSON representation
Java Client for Kong API Gateway configuration
- Host: GitHub
- URL: https://github.com/vaibhav-sinha/kong-java-client
- Owner: vaibhav-sinha
- License: apache-2.0
- Created: 2017-06-12T19:37:00.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-13T16:50:56.000Z (over 6 years ago)
- Last Synced: 2025-07-07T04:44:11.832Z (3 months ago)
- Topics: api-gateway, client-library, java, java-client, kong, kong-java-client
- Language: Java
- Homepage:
- Size: 121 KB
- Stars: 77
- Watchers: 5
- Forks: 46
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Kong Java Client
[Kong](https://getkong.org/) 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
com.github.vaibhav-sinha
kong-java-client
0.2.0
## UsageKongClient 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 TerminationOnly 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)