https://github.com/ahus1/keycloak-dropwizard-integration
This project shows how Red Hat Keycloak and Dropwizard can be used together.
https://github.com/ahus1/keycloak-dropwizard-integration
dropwizard dropwizard-bundle hacktoberfest keycloak
Last synced: about 1 year ago
JSON representation
This project shows how Red Hat Keycloak and Dropwizard can be used together.
- Host: GitHub
- URL: https://github.com/ahus1/keycloak-dropwizard-integration
- Owner: ahus1
- License: apache-2.0
- Created: 2015-08-18T12:28:28.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2025-01-13T16:19:18.000Z (over 1 year ago)
- Last Synced: 2025-04-02T08:48:33.458Z (about 1 year ago)
- Topics: dropwizard, dropwizard-bundle, hacktoberfest, keycloak
- Language: Java
- Homepage: https://ahus1.github.io/keycloak-dropwizard-integration/tutorial.html
- Size: 722 KB
- Stars: 54
- Watchers: 3
- Forks: 16
- Open Issues: 8
-
Metadata Files:
- Readme: README.adoc
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
ifdef::env-github[:outfilesuffix: .adoc]
:ext-relative: {outfilesuffix}
= Integration of Keycloak and Dropwizard
:icons: font
== About
=== Summary
This project shows how Keycloak and Dropwizard can be used together.
At the time I wrote this there was no open source integration of the two, so I set up this project.
ifdef::env-github[To read this tutorial fully rendered, please visit: https://ahus1.github.io/keycloak-dropwizard-integration/tutorial.html.]
ifndef::env-github[To read the latest version of this tutorial, please visit: https://ahus1.github.io/keycloak-dropwizard-integration/tutorial.html.]
http://keycloak.org[Keycloak^] provides a standalone OAuth 2.0 and Open ID Connect server.
It handles user credentials for your application, so you can focus on business requirements.
http://dropwizard.io[Dropwizard^] is a Java framework for developing ops-friendly, high-performance, REST-ful web services.
The versions 1.0.x and 2.0.x of this project showed alternative ways to integrate Keycloak's client libraries with Dropwizard versions 1.x to 3.x.
With Dropwizard version 4.x, Dropwizard upgraded from Java EE to Jakarta EE.
As this would have required additional migration efforts which an unclear added value to users, those have been removed. They might be added in the future if there is co
=== How to use
The module `keycloak-dropwizard` is a ready-to-use Dropwizard module.
The releases are available from Maven central.
The releases depend on a version of Dropwizard and Keycloak that was current at release time.
To use a more recent release, please add them as an explicit dependency to your project, as this project will not release new versions on every minor or patch release of its dependencies.
As Keycloak removed some of its client adapters, the latest version of the Keycloak client libraries to use is 24.0.5.
image:https://img.shields.io/maven-central/v/de.ahus1.keycloak.dropwizard/keycloak-dropwizard-parent[Maven Central,link=https://mvnrepository.com/artifact/de.ahus1.keycloak.dropwizard/keycloak-dropwizard]
image:https://github.com/ahus1/keycloak-dropwizard-integration/workflows/Java%20CI%20with%20Maven/badge.svg?branch=master[Build Status,link=https://github.com/ahus1/keycloak-dropwizard-integration/actions?query=workflow%3A%22Java+CI+with+Maven%22+branch%3Amaster]
* Version 0.7.x is tested with Keycloak 1.9.x and Dropwizard 0.9.x
* Version 0.8.x is tested with Keycloak 2.x.x and Dropwizard 0.9.x
* Version 0.9.x is tested with Keycloak 2.x.x/3.x.x and Dropwizard 1.0.x
* Version 1.0.x is tested with Keycloak 3.x.x and Dropwizard 1.1.x/1.2.x/1.3.x
* Version 1.1.x/1.2.x is tested with Keycloak 4.x-21.x and Dropwizard 1.3.x/2.0.x/2.1.x
* Version 2.x is tested with Keycloak 4.x-23.x and Dropwizard 3.0.x
* Version 3.x is tested with Keycloak 23.x-25.x and Dropwizard 4.0.x
[WARNING]
--
Starting with Dropwizard 2.0 and the included version of Jersey, a login performed during a POST for a form will not recover the contents of the POST.
This is wired into Keycloak's _JettyAdapterSessionStore_ (that restores the content type and the parameters to the request), but Jersey's _InboundMessageContext_ that wants to read the information in the request's header and the body.
See the _shouldLoginFromPost()_ test case for an example.
--
.pom.xml
[source,xml]
----
de.ahus1.keycloak.dropwizard
keycloak-dropwizard
x.x.x
----
The most recent development version (based on the _master_ branch on GitHub) is available from the Sonatype OSS Snapshot Repository. To use it, include the following repository in your _pom.xml_.
.pom.xml
[source,xml]
----
snapshots-repo
https://oss.sonatype.org/content/repositories/snapshots
false
true
----
=== Prerequisites
These examples need a local Keycloak instance with Realm `test` and user `demo` with password `demo`.
Download the Keycloak distribution matching your keycloak-dropwizard-integration version from http://keycloak.org and extract it to a subfolder `keycloak-server` of this directory.
Then call `keycloak-server.bat` to import an already configured realm. Using this startup file the configuration will be reset every time you start Keycloak.
=== Parts
These examples will guide you through setting up Dropwizard and Keycloak in several configurations:
* JAX-RS stateful server sessions +
see https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-jaxrs-example[module keycloak-dropwizard-jaxrs-example^].
* Bearer-Only REST services for Dropwizard +
see https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-ajax-example[module keycloak-dropwizard-ajax-example^].
=== License
Copyright 2015-2023 Alexander Schwartz and the individual contributors.
Licensed under the Apache License, Version 2.0 (the "`License`");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "`AS IS`" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.