GithubHelp home page GithubHelp logo

esse-jacques-dansomon / spring-boot-keycloak Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 2.0 187 KB

This is a simple Spring Boot application that demonstrates how to implement authentication and authorization using Keycloak.

Java 100.00%
aouth2 keycloak oauth2-client spring-boot spring-security

spring-boot-keycloak's Introduction

Spring Boot Keycloak Authentication Demo

This is a simple Spring Boot application that demonstrates how to implement authentication and authorization using Keycloak.

Prerequisites

Before you can run this application, you need to have the following prerequisites installed on your machine:

  • Java 17 or later
  • Maven 3.6 or later
  • Keycloak 18.0 or later

Setup

  1. Clone this repository to your local machine: git clone https://github.com/your-username/spring-boot-keycloak-demo.git

  2. Navigate to the project directory: cd spring-boot-keycloak-demo

  3. Start Keycloak: kb.bat or kb.sh (depending on your operating system) start-dev -Djboss.http.port=8100

  4. Import the realm-export.json file into Keycloak:

    • Open the Keycloak admin console at http://localhost:8080/auth/admin
    • Log in as the admin user (username: admin, password: admin)
    • Click on "Add realm" and select "Import realm"
    • Select the realm-export.json file from the project directory and click "Create"
  5. Build and run the application: mvn spring-boot:run

  6. Test the application:

  • Open a web browser and navigate to http://localhost:8081
  • You should be redirected to the Keycloak login page
  • Log in with one of the predefined users (username: user1 or user2, password: password)
  • You should be redirected back to the home page and see a welcome message with your username

Configuration

The application is configured to use the keycloak realm in Keycloak. The realm-export.json file contains the predefined users and roles used in this demo.

The application properties are defined in the application.properties file:

spring-boot-keycloak's People

Contributors

esse-jacques-dansomon avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

sondos-snd

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.