GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - lambertipablo/resource-server: Reactive resource server microservice using Keycloak as authentication server

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
gradle/wrapper
gradle/wrapper
 
 
src
src
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Read Me First

The following was discovered as part of building this project:

  • The original package name 'com.examples.resource-server' is invalid and this project uses 'com.examples.resource_server' instead.

Getting Started

Purpose

The purpose of this project is to illustrate how to create a reactive resource server microservice, using Keycloak as the authentication server. This project demonstrates the integration of Spring WebFlux for reactive programming and Keycloak for securing the microservice.

Prerequisites

Running Keycloak with Docker

To run Keycloak using Docker, you can use the following command:

docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin jboss/keycloak

This command will start a Keycloak server on port 8080 with the username admin and password admin.

Creating a Client in Keycloak

  1. Open your browser and navigate to http://localhost:8080.
  2. Log in to the Keycloak admin console using the username admin and password admin.
  3. Create a new realm or select an existing realm.
  4. Navigate to the "Clients" section and click on "Create".
  5. Enter demo-service as the client ID.
  6. Set the client protocol to openid-connect.
  7. Set the access type to confidential.
  8. Save the client.
  9. In the "Credentials" tab, note the client secret. You will need this for your application configuration.
  10. In the "Settings" tab, set the "Valid Redirect URIs" to http://localhost:8081/* (or the appropriate URL for your application).
  11. In the "Roles" tab, add any roles that your application requires (e.g., admin, user).
  12. In the "Mappers" tab, add a mapper to include roles in the access token:
    • Click "Create".
    • Enter a name (e.g., roles).
    • Set the "Mapper Type" to User Realm Role.
    • Set the "Token Claim Name" to roles.
    • Set the "Claim JSON Type" to String.
    • Save the mapper.

Obtaining an Access Token Using Keycloak

To obtain an access token from Keycloak, follow these steps:

  1. Open Postman.
  2. Create a new POST request.
  3. Set the request URL to http://localhost:8080/realms/{realm-name}/protocol/openid-connect/token.
    • Replace {realm-name} with the name of your realm.
  4. In the "Authorization" tab, select "Basic Auth" and enter the client ID and client secret.
    • Username: demo-service
    • Password: [client secret from Keycloak]
  5. In the "Body" tab, select "x-www-form-urlencoded" and add the following parameters:
    • grant_type: password
    • username: [your Keycloak username]
    • password: [your Keycloak password]
  6. Click "Send" to obtain the access token.

Testing Endpoints Using Postman

To test the endpoints using Postman, follow these steps:

  1. Open Postman.
  2. Create a new GET request.
  3. Set the request URL to http://localhost:8081/api/sample-entities (or the appropriate endpoint URL).
  4. In the "Authorization" tab, select "Bearer Token" and enter the access token obtained from Keycloak.
  5. Click "Send" to test the endpoint.

Reference Documentation

For further reference, please consider the following sections:

  • Official Gradle documentation
  • Spring Boot Gradle Plugin Reference Guide
  • Create an OCI image
  • Spring Reactive Web

Guides

The following guides illustrate how to use some features concretely:

  • Building a Reactive RESTful Web Service

Additional Links

These additional references should also help you:

  • Gradle Build Scans – insights for your project's build

About

Reactive resource server microservice using Keycloak as authentication server

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.