fdelbrayelle / generator-jhipster-kafka

A JHipster module that generates Apache Kafka consumers and producers and more!
Apache License 2.0
28 stars 10 forks source link

Get a 401 when producing a message #102

Closed fdelbrayelle closed 3 years ago

fdelbrayelle commented 3 years ago
Overview of the issue
Motivation for or Use Case
Reproduce the error
  1. Create a new test project: mkdir test && cd test && jhipster
  2. Create a new entity Foo with a String field bar: jhipster entity Foo
  3. Use the Kafka module to generate a consumer and a producer for the Foo entity: yo jhipster-kafka
  4. Run the Kafka broker: docker-compose -f src/main/docker/kafka.yml up
  5. Run the application: ./mvnw
  6. Get a JWT token by authenticating:
token=`curl -X POST localhost:8080/api/authenticate -d '{ "username": "admin", "password": "admin" }' -H "Content-Type: application/json"|jq '.id_token'`
  1. Call the producer through the Kafka REST resource with bad fields for Foo: curl -X POST localhost:8080/api/foos/kafka -H "Authorization: Bearer $token" -d '{ "foo": "foo" }' -H 'Content-Type: application/json'

  2. :boom: :

{
  "type" : "https://www.jhipster.tech/problem/problem-with-message",
  "title" : "Unauthorized",
  "status" : 401,
  "detail" : "Full authentication is required to access this resource",
  "path" : "/api/foos/kafka",
  "message" : "error.http.401"
}%     
Related issues
Suggest a Fix
JHipster Version(s)
JHipster configuration
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
fdelbrayelle commented 3 years ago

Was missing -r option in jq command :-1: