Skip to content

Commit

Permalink
KEYCLOAK-4384 Remove Mongo support
Browse files Browse the repository at this point in the history
  • Loading branch information
stianst committed Feb 15, 2017
1 parent 06da1d1 commit 49ac358
Show file tree
Hide file tree
Showing 164 changed files with 16 additions and 18,214 deletions.
9 changes: 0 additions & 9 deletions dependencies/server-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-core</artifactId>
</dependency>
<!-- mongo -->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-model-mongo</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</dependency>

<dependency>
<groupId>org.liquibase</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ if (result == []) of /profile=$clusteredProfile/subsystem=keycloak-server/:read-
echo
end-if

# Find if we are using jpa or mongo
if (result == mongo) of /profile=$clusteredProfile/subsystem=keycloak-server/spi=realm/:read-attribute(name=default-provider)
set persistenceProvider=mongo
else
set persistenceProvider=jpa
end-if
set persistenceProvider=jpa

# Migrate from 2.1.0 to 2.2.0
if (outcome == failed) of /profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=authorization/:read-resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ if (result == []) of /profile=$standaloneProfile/subsystem=keycloak-server/:read
echo
end-if

# Find if we are using jpa or mongo
if (result == mongo) of /profile=$standaloneProfile/subsystem=keycloak-server/spi=realm/:read-attribute(name=default-provider)
set persistenceProvider=mongo
else
set persistenceProvider=jpa
end-if
set persistenceProvider=jpa

# Migrate from 2.1.0 to 2.2.0
if (result == update) of /profile=$standaloneProfile/subsystem=keycloak-server/spi=connectionsJpa/provider=default/:map-get(name=properties,key=databaseSchema)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ if (result == []) of /subsystem=keycloak-server/:read-children-names(child-type=
echo
end-if

# Find if we are using jpa or mongo
if (result == mongo) of /subsystem=keycloak-server/spi=realm/:read-attribute(name=default-provider)
set persistenceProvider=mongo
else
set persistenceProvider=jpa
end-if
set persistenceProvider=jpa

# Migrate from 2.1.0 to 2.2.0
if (outcome == failed) of /extension=org.jboss.as.deployment-scanner/:read-resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ if (result == []) of /subsystem=keycloak-server/:read-children-names(child-type=
echo
end-if

# Find if we are using jpa or mongo
if (result == mongo) of /subsystem=keycloak-server/spi=realm/:read-attribute(name=default-provider)
set persistenceProvider=mongo
else
set persistenceProvider=jpa
end-if
set persistenceProvider=jpa

# Migrate from 2.1.0 to 2.2.0
if (outcome == failed) of /extension=org.jboss.as.deployment-scanner/:read-resource
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<module name="org.keycloak.keycloak-server-spi" services="import"/>
<module name="org.keycloak.keycloak-server-spi-private" services="import"/>
<module name="org.keycloak.keycloak-model-jpa" services="import"/>
<module name="org.keycloak.keycloak-model-mongo" services="import"/>
<module name="org.keycloak.keycloak-model-infinispan" services="import"/>
<module name="org.keycloak.keycloak-saml-core-public" services="import"/>
<module name="org.keycloak.keycloak-saml-core" services="import"/>
Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions misc/DatabaseTesting.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
Test with various databases
===========================

MongoDB
-------

The Keycloak testsuite uses an embedded MongoDB when running tests so you don't have to have one running locally.

Run tests:

mvn install -Pmongo


MySQL
-----

Expand Down
12 changes: 0 additions & 12 deletions misc/Testsuite.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ For example to use the example themes run the server with:

**NOTE:** If `keycloak.theme.dir` is specified the default themes (base, rcue and keycloak) are loaded from the classpath

### Run server with Mongo model

To start a Keycloak server with identity model data persisted in Mongo database instead of default JPA/H2 you can run:

mvn exec:java -Pkeycloak-server -Dkeycloak.realm.provider=mongo -Dkeycloak.user.provider=mongo -Dkeycloak.audit.provider=mongo

By default it's using database `keycloak` on localhost/27017 and it uses already existing data from this DB (no cleanup of existing data during bootstrap). Assumption is that you already have DB running on localhost/27017 . Use system properties to configure things differently:

mvn exec:java -Pkeycloak-server -Dkeycloak.realm.provider=mongo -Dkeycloak.user.provider=mongo -Dkeycloak.eventStore.provider=mongo -Dkeycloak.connectionsMongo.host=localhost -Dkeycloak.connectionsMongo.port=27017 -Dkeycloak.connectionsMongo.db=keycloak -Dkeycloak.connectionsMongo.clearOnStartup=false

Note that if you are using Mongo model, it would mean that Mongo will be used for audit as well. You may need to use audit related properties for configuration of Mongo if you want to override default ones (For example keycloak.audit.mongo.host, keycloak.audit.mongo.port etc)

TOTP codes
----------

Expand Down
18 changes: 2 additions & 16 deletions misc/UpdatingDatabaseSchema.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Updating Database Schema
========================

Keycloak supports automatically migrating the database to a new version. This is done by applying one or more change-sets
to the existing database. This means if you need to do any changes to database schemas for JPA or Mongo you need to create
to the existing database. This means if you need to do any changes to database schemas you need to create
a change-set that can transform the schema as well as any existing data.

This includes changes to:
Expand All @@ -13,7 +13,7 @@ This includes changes to:
* Event entities


Creating a JPA change-set
Creating a change-set
-------------------------

We use Liquibase to support updating the database. The change-sets are located in
Expand Down Expand Up @@ -57,20 +57,6 @@ Once the server has started fully, stop it and run:
mvn -f testsuite/integration exec:java -Pkeycloak-server -Dkeycloak.connectionsJpa.url='jdbc:h2:keycloak' -Dkeycloak.connectionsJpa.databaseSchema='development-validate'


Creating a Mongo change-set
---------------------------

As Mongo is schema-less it's significantly easier to create a change-set. You only need to create/delete collections as
needed, as well as update any indexes. You will also need to update existing data if required.

Mongo change-sets are written in Java and are located in the `connections/mongo` module, to add a new change-set create
a new class that implements `org.keycloak.connections.mongo.updater.updates.Update` the name of the class should be
`Update<version>` with `.` replaced with `_`.

You also need to add a reference to this file in `org.keycloak.connections.mongo.updater.DefaultMongoUpdaterProvider`.
It should be added last to the `DefaultMongoUpdaterProvider#updates` array.


Testing database migration
--------------------------

Expand Down
17 changes: 8 additions & 9 deletions misc/UpdatingServerConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,22 @@ The changes you will likely make are when you need to add a new SPI, change an e
All elements in an SPI declaration are optional, but a full SPI declaration
looks like this:
````xml
<spi name="dblock">
<default-provider>mongo</default-provider>
<provider name="jpa" enabled="true">
<spi name="example">
<default-provider>myprovider</default-provider>
<provider name="myprovider" enabled="true">
<properties>
<property name="lockWaitTimeout" value="800"/>
<property name="key" value="value"/>
</properties>
</provider>
<provider name="mongo" enabled="true">
<provider name="mypotherrovider" enabled="true">
<properties>
<property name="lockRecheckTime" value="2"/>
<property name="lockWaitTimeout" value="600"/>
<property name="key" value="value2"/>
</properties>
</provider>
</spi>
````
Here we have two providers defined for the SPI `dblock`. The
`default-provider` is listed as `mongo`. However it is up to the SPI to decide how it will
Here we have two providers defined for the SPI `example`. The
`default-provider` is listed as `myprovider`. However it is up to the SPI to decide how it will
treat this setting. Some SPIs allow more than one provider and some do not. So
`default-provider` can help the SPI to choose.

Expand Down
75 changes: 0 additions & 75 deletions model/mongo/pom.xml

This file was deleted.

Loading

0 comments on commit 49ac358

Please sign in to comment.