Skip to content

Keycloak provider for user federation in Postgres

Notifications You must be signed in to change notification settings

shvyrev/kc-pg-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keycloak provider for user federation in Postgres

This project demonstrates the ability to use Postgres as user storage provider of Keycloak.

Requirements

The following software is required to work build it locally:

See the links above for installation instructions on your platform. You can verify the versions are installed and running:

$ git --version
$ curl -V
$ mvn -version
$ docker --version
$ java --version

Usage

Docker containers

Postgres - database for which we want to store User Federation.

Keycloak - KC container with custom certificate, for use over https. The container is described in Dockerfile.

Build SPI provider

Before you build the SPI provider you must add the information about the database. This information is specified in the file persistence.xml

⚠️ Replace the URI jdbc:postgresql://localhost:5432/keycloak with your database address.

Using Postgres

⚠️ I recommend using your own database, cause not all systems will have a database at localhost available to the docker container.

To deploy the container use the script :

$ sh/pg

The script deploys the container locally.

It uses port : 5432.

The scripts in the container create a keycloak database. In the database create a table users :

create table users
(
    id uuid not null primary key,
    username varchar(255),
    password varchar(255)
)

Add mock user to the table.

Using Keycloak

KC is deployed in a custom container.

To deploy the KC container, I created a Dockerfile file in which :

  • I create a certificate for https access
  • I add a provider kc-pg-provider

Build the project

Run the script :

$ sh/run

This script will build the SPI provider.

Deploys the KC container, adds the SPI provider and restarts the container to apply the changes.

Login to KC

After launching, go to https://localhost:8443 in your browser. To log in to KC, use admin credentials :

user : admin
pass : admin

Click the User federation tab .

The provider kc-pg-provider is in list of providers.

KC providers

About

Keycloak provider for user federation in Postgres

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published