Coder Social home page Coder Social logo

germanfica / tut-keycloak-user-storage-spi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hexadefence/user-storage-spi-example

0.0 1.0 0.0 142 KB

I'm following the @hexadefence tutorial video.

Home Page: https://youtu.be/Og95LuvYMXA

Java 100.00%
keycloak-spi maven java-11

tut-keycloak-user-storage-spi's Introduction

User Storage SPI Example

This repository provides a maven project to connect to external user in-memory database.

✨ Getting Started πŸš€ Download

Getting Started

Follow the below instructions to get started with the source code:

Requirements

Make sure you have the below requirements before starting:

Download

You can get access to the source code by using one of the following ways:

  • ✨ Download Source Code
  • πŸ”₯ Clone the repository locally:
git clone https://github.com/germanfica/user-storage-spi-example.git

Keycloak Server SPI Getting Started

You can use the User Storage SPI to write extensions to Keycloak to connect to external user databases and credential stores. The built-in LDAP and ActiveDirectory support is an implementation of this SPI in action.

If you want to know more, see below the official Keycloak documentation.

Add user federation provider

Let’s add our first provider.

  1. Open the Keycloak Admin Console

  2. Hover the mouse over the dropdown in the top-left corner where it says Master, then click on Myrealm

  3. Click User Federation

  4. Fill in the form with the following values:

    • Add provider: hashmap-user-store

step_1

Done, now let's save the provider. To do this:

  1. Click Save

step_2

That's it, we now have our user federation available.

user-federation

Add default roles to users

If you want you can add default roles.

default-roles

Install maven

Follow the official maven guide below:

pom.xml

 <properties>
     <maven.compiler.release>11</maven.compiler.release>
 </properties>

 <build>
     <pluginManagement>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>3.10.0</version>
             </plugin>
         </plugins>
     </pluginManagement>
 </build>

Maven commands

  • mvn clean
  • mvn clean install

Configuration

Open org.keycloak.storage.UserStorageProviderFactory

com.hexadefence.userstoragespi.HashMapStorageProviderFactory

Maven dependencies

Apache Maven Compiler Plugin

<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.10.0</version>
</dependency>

Keycloak Server SPI

<!-- https://mvnrepository.com/artifact/org.keycloak/keycloak-server-spi -->
<dependency>
    <groupId>org.keycloak</groupId>
    <artifactId>keycloak-server-spi</artifactId>
    <version>17.0.0</version>
    <scope>provided</scope>
</dependency>

Deploy app in Keycloak Amazon Lightsail server

scp -i YourLightsailDefaultKey.pem "D:\workspace\user-storage-spi-example\target\user-storage-spi.jar" [email protected]:"/home/ubuntu/keycloak-myrealm/standalone/deployments/user-storage-spi.jar"

Credits

tut-keycloak-user-storage-spi's People

Contributors

germanfica avatar hexadefence avatar

Watchers

James Cloos 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.