<commit_before>ifdef::env-github[:outfilesuffix: .adoc]
:ext-relative: {outfilesuffix}

# Integration of Keycloak and Dropwizard

## About

### Summary

This project shows how JBoss Keycloak and Dropwizard can be used together.

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[JBoss Keycloak^] provides a standalone OAuth 2.0 and Open ID Connect server.
It handles user credentials for you application, so you can focus on business requirements.

http://dropwizard.io[Dropwizard^] is a Java framework for developing ops-friendly, high-performance, RESTful web services.

*TL;DR:* The module
https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-jaxrs-example[keycloak-dropwizard-jaxrs-example]
shows how to use Dropwizard's `@Auth` annotation with Keycloak using a full OAuth flow.

At the time I write this there is no open source integration of the two, so I set up this project.
See https://github.com/ahus1/keycloak-dropwizard-integration for the latest version.

### How to use

The module `keycloak-dropwizard-jaxrs` is evolving into a ready-to-user Dropwizard module. The first releases are now available (currently on jcenter and in my personal Bintray repository):

image::https://api.bintray.com/packages/ahus1/maven/keycloak-dropwizard/images/download.svg[link="https://bintray.com/ahus1/maven/keycloak-dropwizard/_latestVersion"]

.pom.xml
----
<repositories>
  <repository>
    <id>bintray-ahus1</id>
    <name>Maven Repository of <NAME></name>
    <url>https://dl.bintray.com/ahus1/maven/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>de.ahus1.keycloak.dropwizard</groupId>
    <artifactId>domain</artifactId>
    <version>0.x.x</version>
  </dependency>
</dependencies>
----

### Prerequisites

These examples need a local JBoss Keycloak instance with Realm `test` and user `demo` with password `<PASSWORD>`.

Please download the Keycloak distribution version 1.4.0 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

This example will guide you through setting up JBoss Keycloak in several configurations:

  * Simple Integration Servlet style for http://dropwizard.io[Dropwizard^] +
    see  https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-jetty[module keycloak-dropwizard-jetty^].
  * Advanced Integration http://dropwizard.io[Dropwizard^] style +
    see https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-jaxrs[module keycloak-dropwizard-jaxrs^].
    and https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-jaxrs-example[module keycloak-dropwizard-example^].
  * Bearer-Only REST services for http://dropwizard.io[Dropwizard^] +
    see https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-bearer[module keycloak-dropwizard-bearer^].

For completeness and an even simple setup a standard Servlet configuration is also included (without and with Keycloak):

  * Simple Servlet +
    see https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/simple-war[module simple-war^].
  * Servlet with Keycloak +
    see  https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-war[module keycloak-war^].

### License

Copyright 2015 <NAME>

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.
<commit_msg>fixing typo #2<commit_after>ifdef::env-github[:outfilesuffix: .adoc]
:ext-relative: {outfilesuffix}

# Integration of Keycloak and Dropwizard

## About

### Summary

This project shows how JBoss Keycloak and Dropwizard can be used together.

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[JBoss Keycloak^] provides a standalone OAuth 2.0 and Open ID Connect server.
It handles user credentials for you application, so you can focus on business requirements.

http://dropwizard.io[Dropwizard^] is a Java framework for developing ops-friendly, high-performance, RESTful web services.

*TL;DR:* The module
https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-jaxrs-example[keycloak-dropwizard-jaxrs-example]
shows how to use Dropwizard's `@Auth` annotation with Keycloak using a full OAuth flow.

At the time I write this there is no open source integration of the two, so I set up this project.
See https://github.com/ahus1/keycloak-dropwizard-integration for the latest version.

### How to use

The module `keycloak-dropwizard-jaxrs` is evolving into a ready-to-use Dropwizard module. The first releases are now available (currently on jcenter and in my personal Bintray repository):

image::https://api.bintray.com/packages/ahus1/maven/keycloak-dropwizard/images/download.svg[link="https://bintray.com/ahus1/maven/keycloak-dropwizard/_latestVersion"]

.pom.xml
----
<repositories>
  <repository>
    <id>bintray-ahus1</id>
    <name>Maven Repository of <NAME></name>
    <url>https://dl.bintray.com/ahus1/maven/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>de.ahus1.keycloak.dropwizard</groupId>
    <artifactId>domain</artifactId>
    <version>0.x.x</version>
  </dependency>
</dependencies>
----

### Prerequisites

These examples need a local JBoss Keycloak instance with Realm `test` and user `demo` with password `<PASSWORD>`.

Please download the Keycloak distribution version 1.4.0 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

This example will guide you through setting up JBoss Keycloak in several configurations:

  * Simple Integration Servlet style for http://dropwizard.io[Dropwizard^] +
    see  https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-jetty[module keycloak-dropwizard-jetty^].
  * Advanced Integration http://dropwizard.io[Dropwizard^] style +
    see https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-jaxrs[module keycloak-dropwizard-jaxrs^].
    and https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-jaxrs-example[module keycloak-dropwizard-example^].
  * Bearer-Only REST services for http://dropwizard.io[Dropwizard^] +
    see https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-dropwizard-bearer[module keycloak-dropwizard-bearer^].

For completeness and an even simple setup a standard Servlet configuration is also included (without and with Keycloak):

  * Simple Servlet +
    see https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/simple-war[module simple-war^].
  * Servlet with Keycloak +
    see  https://github.com/ahus1/keycloak-dropwizard-integration/tree/master/keycloak-war[module keycloak-war^].

### License

Copyright 2015 <NAME>

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.

{'fraction_non_alphanumeric': 0.10342830669446375, 'fraction_numerical': 0.006833449154505443, 'mean_word_length': 4.799194089993284, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 26, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1938984', 'n_tokens_mistral': 2824, 'n_tokens_neox': 2631, 'n_words': 772}