Giter Club home page Giter Club logo

keycloak-event-listener-http's Introduction

keycloak-event-listener-http

A Keycloak SPI that publishes events to an HTTP Webhook. A combination of @jessylenne/keycloak-event-listener-http SPI and the keycloak-event-listener-rabbitmq SPI. Extended by @darrensapalo to enable building the JAR files from docker images.

Build

Build on your local machine

mvn clean install

Build using docker

Alternatively, you can build the JAR files from a docker image. You must have docker installed.

  1. Run make package-image.
  2. The JAR files should show up on your mvn-output folder.

If you encounter the following issue:

open {PATH}/mvn-output/event-listener-http-jar-with-dependencies.jar: permission denied

Simply add write permissions to the mvn-output folder:

sudo chown $USER:$USER mvn-output

Deploy

  • Copy target/event-listener-http-jar-with-dependencies.jar to {KEYCLOAK_HOME}/standalone/deployments

Configuration

Option 1

  • Configure the following env variables :

  • Restart the keycloak server.

Option 2

  • Edit standalone.xml to configure the Webhook settings. Find the following section in the configuration:
<subsystem xmlns="urn:jboss:domain:keycloak-server:1.1">
    <web-context>auth</web-context>

And add below:

<spi name="eventsListener">
    <provider name="mqtt" enabled="true">
        <properties>
            <property name="serverUri" value="http://127.0.0.1:8080/webhook"/>
            <property name="username" value="auth_user"/>
            <property name="password" value="auth_password"/>
        </properties>
    </provider>
</spi>

Leave username and password out if the service allows anonymous access.

  • Restart the keycloak server.

Usage

Add/Update a user, your webhook should be called, looks at the keycloak syslog for debug

Request example

{
{
  '@class': 'org.softwarefactory.keycloak.providers.events.http.AdminEventNotification',
  id: null,
  time: 1644281802199,
  realmId: 'github',
  authDetails: {
    realmId: 'master',
    clientId: '0caa5a71-c84c-461f-94ee-7b862ad47608',
    userId: '8f8b083b-9cca-45eb-a839-99cd41ae77d9',
    ipAddress: '172.0.0.1'
  },
  resourceType: 'USER',
  operationType: 'UPDATE',
  resourcePath: 'users/d57594cd-7425-492f-a3a7-4576d51ea745',
  representation: '{"id":"d57594cd-7425-492f-a3a7-4576d51ea745","createdTimestamp":1642815331413,"username":"abdoulaye.traore","enabled":true,"totp":false,"emailVerified":true,"firstName":"firstN me","lastName":"lastName","email":"[email protected]","attributes":{},"disableableCredentialTypes":[],"requiredActions":["UPDATE_PASSWORD"],"notBefore":0,"access":{"manageGroupMembership":true,"view":true,"mapRoles":true,"impersonate":true,"manage":true}}',
  error: null,
  resourceTypeAsString: 'USER'
}
}

keycloak-event-listener-http's People

Contributors

aktraore avatar darrensapalo avatar jessylenne avatar oojikoo avatar

Watchers

 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.