This is a boilerplate project to create a Spring Boot application with GraphQL and KeyCloak integration.
- Supported both GraphQL and REST APIs
- KeyCloak integration with the following features:
- Single sign-on (SSO)
- Login
- Logout
- Forgot password
- Register
- Reset password
- Admin panel
- And much more...
- GraphiQL playground
- Spring Boot DevTools
- Already configured with PostgreSQL drivers and JPA
- Spring Boot v3 (View configuration here):
- Spring for GraphQL
- Spring Web
- Lombok
- Spring Boot DevTools
- Spring Data JPA
- PostgreSQL Driver
- KeyCloak v21 + Spring Security
- GraphQL + GraphiQL
- Maven
- Start PostgreSQL container using Docker Compose
docker-compose up -d
- Run KeyCloak container
chmod -x ./start-keycloak.sh && ./start-keycloak.sh
After the container is up and running, you can access the KeyCloak admin panel at http://localhost:8082/ with the following credentials:
- Username:
admin
- Password:
admin
Notice: Unfortunately, you can change the username and password by editing the
start-keycloak.sh
file.
- Setup KeyCloak realm and application client
Since KeyCloak is not part of this project, you need to manually setup the KeyCloak realm and application client.
You can follow the official documentation here.
- Edit the
application.properties
file
You need to update the configured KeyCloak realm and client ID (and secret if you have one).
spring.security.oauth2.client.provider.keycloak.issuer-uri=http://localhost:8082/realms/<REALM NAME>
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:8082/realms/<REALM NAME>
spring.security.oauth2.client.registration.keycloak.client-id=<CLIENT NAME>
spring.security.oauth2.client.registration.keycloak.client-secret=<CLIENT SECRET>
- Run the application with Maven
mvn spring-boot:run