Securing Spring Boot microservice using Keycloak and Testcontainers
Table of contents
Learn how to create an OAuth 2.0 Resource Server using Spring Boot, secure API
endpoints with Keycloak, and test the application using the Testcontainers Keycloak module.
Time to complete
30 minutes
In this guide, you'll learn how to:
- Create an OAuth 2.0 Resource Server using Spring Boot
- Secure API endpoints using Keycloak
- Test the APIs using the Testcontainers Keycloak module
- Run the application locally using the Testcontainers Keycloak module
Prerequisites
- Java 17+
- Maven or Gradle
- A Docker environment supported by Testcontainers
NoteIf you're new to Testcontainers, visit the Testcontainers overview to learn more about Testcontainers and the benefits of using it.
Modules
- Create the project
Set up a Spring Boot OAuth 2.0 Resource Server with Keycloak, PostgreSQL, and Testcontainers.
- Write tests
Test the secured Spring Boot API endpoints using Testcontainers Keycloak and PostgreSQL modules.
- Run tests
Run your Testcontainers-based Spring Boot Keycloak integration tests and explore next steps.