Skip to content

confluentinc/kafka-connect-http-demo

Repository files navigation

Kafka Connect HTTP Sink Demo App

NOTICE: This app is for demo purposes only and is not suitable for production use.

A Spring Boot app that can run with various types of auth configured by setting the appropriate Spring Profile.

This app is useful in testing the HTTP Sink Connector.

Supported Security Types

  • Simple Auth (No Authentication) (Profile: simple-auth)
  • Basic Auth (Profile: basic-auth)
  • OAuth2 (Profile: oauth2)
  • SSL (Profile: ssl-auth)

Simple (No) Auth

  1. Set profile

    SPRING_PROFILES_ACTIVE=simple-auth
    
  2. Run the app

  3. Call any endpoint

    # create a message
    curl -X POST \
      http://localhost:8080/api/messages \
      -d message-goes-here
      
    # get all messages
    curl http://localhost:8080/api/messages

Basic Auth

  1. Set profile

    SPRING_PROFILES_ACTIVE=basic-auth
    
  2. Run the app

  3. Call endpoints with Basic Auth Header

    # create a message
    curl -X POST \
      http://localhost:8080/api/messages \
      -H 'Authorization: Basic YWRtaW46cGFzc3dvcmQ=' \
      -d message-goes-here
    
    # get all messages
    curl \
      http://localhost:8080/api/messages \
      -H 'Authorization: Basic YWRtaW46cGFzc3dvcmQ='

OAuth2

  1. Set profile

    SPRING_PROFILES_ACTIVE=oauth2
    
  2. Run the app

  3. Create Token

    curl -X POST \
      http://localhost:8080/oauth/token \
      -H 'Content-Type: application/x-www-form-urlencoded' \
      -H 'Authorization: Basic a2MtY2xpZW50OmtjLXNlY3JldA==' \
      -d 'grant_type=client_credentials&scope=any'
  4. Use Token (substitute {token} with value from previous step)

    # create a message
    curl -X POST \
      http://localhost:8080/api/messages \
      -H 'Authorization: Bearer {token}'
      -d message-goes-here
      
    # get all messages
    curl \
        http://localhost:8080/api/messages \
        -H 'Authorization: Bearer {token}'
    

SSL

  1. Set profile
    SPRING_PROFILES_ACTIVE=ssl-auth
    
  2. Use cert in root of project to call endpoints

Notes:

  • port 8443 is used instead of 8080
  • Keystore was generated with this command:
     keytool -genkeypair -alias tomcat -keyalg RSA -keysize 2048 
    -keystore keystore.jks -validity 3650

About

A demo target for running the Confluent HTTP sink connector

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published