https://github.com/piomin/sample-spring-security-microservices
Demo illustrating the usage of Spring Security in microservices built on top of Spring Boot and Spring Cloud
https://github.com/piomin/sample-spring-security-microservices
keycloak microservices oauth2 spring-boot spring-cloud-gateway spring-security spring-security-oauth2
Last synced: 3 months ago
JSON representation
Demo illustrating the usage of Spring Security in microservices built on top of Spring Boot and Spring Cloud
- Host: GitHub
- URL: https://github.com/piomin/sample-spring-security-microservices
- Owner: piomin
- Created: 2020-10-09T12:36:00.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-03-21T12:45:28.000Z (3 months ago)
- Last Synced: 2025-03-29T01:14:04.032Z (3 months ago)
- Topics: keycloak, microservices, oauth2, spring-boot, spring-cloud-gateway, spring-security, spring-security-oauth2
- Language: Java
- Homepage: https://piotrminkowski.com
- Size: 156 KB
- Stars: 109
- Watchers: 4
- Forks: 57
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Example Project for Security in Spring Boot and Microservices [](https://twitter.com/piotr_minkowski)
[](https://circleci.com/gh/piomin/sample-spring-security-microservices)
[](https://sonarcloud.io/dashboard?id=piomin_sample-spring-security-microservices)
[](https://sonarcloud.io/dashboard?id=piomin_sample-spring-security-microservices)
[](https://sonarcloud.io/dashboard?id=piomin_sample-spring-security-microservices)
[](https://sonarcloud.io/dashboard?id=piomin_sample-spring-security-microservices)In this project I'm demonstrating you the most interesting features of [Spring Cloud Project](https://spring.io/projects/spring-cloud) for building microservice-based architecture.
-----
I'm publishing on my blog and maintaining example repositories just as a hobby. But if you feel it's worth donating:
[](https://ko-fi.com/piotrminkowski)
1. How to renew certificates in your Spring Boot apps on Kubernetes with **Cert Manager** and **Stakater Reloader**. The example is available in the branch [master](https://github.com/piomin/sample-spring-security-microservices/tree/master). A detailed guide may be found in the following article: [Renew Certificates on Kubernetes with Cert Manager and Reloader](https://piotrminkowski.com/2022/12/02/renew-certificates-on-kubernetes-with-cert-manager-and-reloader/)
2. How to reload `SslBundles` with Spring Boot and run the apps on Kubernetes. A detailed guide may be found in the following article: [Spring Boot SSL Hot Reload on Kubernetes](https://piotrminkowski.com/2024/02/19/spring-boot-ssl-hot-reload-on-kubernetes/)
3. How to use OAuth2 with Spring Cloud and integrate Spring Boot app with **Keycloak**. A detailed guide may be found in the following article: [Microservices with Spring Cloud Gateway, OAuth2 and Keycloak](https://piotrminkowski.com/2024/03/01/microservices-with-spring-cloud-gateway-oauth2-and-keycloak/)
4. How to use SAML2 with Spring Boot and integrate it with **Keycloak** through the OpenSAML **Shibboleth** library. A detailed guide may be found in the following article: [Spring Boot with SAML2 and Keycloak](https://piotrminkowski.com/2024/10/28/spring-boot-with-saml2-and-keycloak/)## Getting Started
### SSL
To access an example with Spring Boot `SSLBundle` go to the `ssl` directory.
First, run the `secure-callme-bundle` app:
```shell
cd ssl/secure-callme-bundle
mvn spring-boot:run
```First, run the `secure-caller-bundle` app:
```shell
cd ssl/secure-caller-bundle
mvn spring-boot:run
```Then call the endpoint exposed by the with the curl command:
```shell
curl https://localhost:8444/caller/ping --insecure
```### SAML2
To access an example with Spring Boot SAML 2.0 example go to the `saml` directory.
First, run the Keycloak container:
```shell
cd saml
docker compose up
```Once the Keycloak is started go to `callme-saml` and run the app:
```shell
cd callme-saml
mvn spring-boot:run
```### OAuth2
To access an example with Spring Boot OAuth2 example go to the `oauth` directory.
While building the `gateway` app it runs Testcontainer with Keycloak and simulates a downstream service:
```shell
cd oauth/gateway
mvn clean package
```