Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhooks fail with --features=declarative-user-profile #11

Open
kecskesalbert opened this issue Sep 20, 2023 · 3 comments
Open

Webhooks fail with --features=declarative-user-profile #11

kecskesalbert opened this issue Sep 20, 2023 · 3 comments
Assignees

Comments

@kecskesalbert
Copy link

After experimental feature: declarative-user-profile are enabled, and a custom attribute is added to the user profile, webhooks aren't sent. An error message is logged on the console instead:
"Could not send webhook: java.lang.UnsupportedOperationException: responseBody currently only supports JSON body"

This might be related to the static schema defined in openapi/webhook.open-api.yml, and perhaps to OpenAPITools/openapi-generator#2944.

@stephane-segning
Copy link
Contributor

Can you please provide steps to reproduce it? I'm interested in fixing it

@lucasboinet
Copy link

Here is details about the error i have the same issue :)

The error in keycloak logs :

2024-05-31 16:41:03,928 ERROR [com.vymalo.keycloak.webhook.WebhookEventListenerProvider] (executor-thread-2) Could not send webhook: java.lang.UnsupportedOperationException: responseBody currently only supports JSON body.
        at com.vymalo.keycloak.openapi.client.handler.WebhookApi.sendWebhookWithHttpInfo(WebhookApi.kt:400)
        at com.vymalo.keycloak.openapi.client.handler.WebhookApi.sendWebhook(WebhookApi.kt:61)
        at com.vymalo.keycloak.webhook.service.HttpWebhookHandler.sendWebhook(HttpWebhookHandler.kt:21)
        at com.vymalo.keycloak.webhook.WebhookEventListenerProvider.send(WebhookEventListenerProvider.kt:86)
        at com.vymalo.keycloak.webhook.WebhookEventListenerProvider.onEvent(WebhookEventListenerProvider.kt:23)
        at org.keycloak.events.EventBuilder.sendNow(EventBuilder.java:266)
        at org.keycloak.events.EventBuilder.send(EventBuilder.java:253)
        at org.keycloak.events.EventBuilder.success(EventBuilder.java:221)
        at org.keycloak.services.managers.AuthenticationManager.finishedRequiredActions(AuthenticationManager.java:1031)
        at org.keycloak.authentication.AuthenticationProcessor.authenticationComplete(AuthenticationProcessor.java:1157)
        at org.keycloak.authentication.AuthenticationProcessor.authenticationAction(AuthenticationProcessor.java:1019)
        at org.keycloak.services.resources.LoginActionsService.processFlow(LoginActionsService.java:365)
        at org.keycloak.services.resources.LoginActionsService.processAuthentication(LoginActionsService.java:336)
        at org.keycloak.services.resources.LoginActionsService.authenticate(LoginActionsService.java:328)
        at org.keycloak.services.resources.LoginActionsService.authenticateForm(LoginActionsService.java:393)
        at org.keycloak.services.resources.LoginActionsService$quarkusrestinvoker$authenticateForm_32b8e198ac3110abd1d5774e83a4cf87858129f4.invoke(Unknown Source)
        at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
        at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:582)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:840)

Here is the docker-compose configuration for my local setup :

keycloak:
    image: quay.io/keycloak/keycloak:latest
    environment:
      KC_DB: "XXXXX"
      KC_DB_PASSWORD: "XXXX"
      KC_DB_URL: "XXXX"
      KC_DB_USERNAME: "XXX"

      KEYCLOAK_ADMIN: "admin"
      KEYCLOAK_ADMIN_PASSWORD: "admin"
      WEBHOOK_HTTP_BASE_PATH: "http://node:3000/api/webhooks/keycloak" // node:3000 is my local nodejs api
      WEBHOOK_EVENTS_TAKEN: "LOGIN,REGISTER"
      WEBHOOK_HTTP_AUTH_USERNAME: "admin"
      WEBHOOK_HTTP_AUTH_PASSWORD: "password"
    ports:
      - 8443:8080
    volumes:
      - ./providers:/opt/keycloak/providers
    command:
      - start-dev

I just started the my api, my frontend (vuejs app) and my keycloak but when i login this error happen and nothing is sent to the webhook url. Do you need anything else ?

@lucasboinet
Copy link

Okay i think i figured out what was the problem, the webhook endpoint response need to be JSON. I was sending the result with res.sendStatus(200) but it work when i do the result with json response res.json({ success: true })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants