Skip to content

aelkz/springboot-open-id-connect-sample

Repository files navigation

Springboot OpenID Connect sample app

modules: spring-boot-starter-security, pring-boot-starter-oauth2-resource-server, spring-boot-starter-oauth2-client
authorization server: keycloak
  1. Start Red Hat Single Sign-On (keycloak)
  2. Create a new master realm admin user
  3. Create a new realm: sample
  4. Under sample realm, create a new user (usr/pwd): john/doe
  5. Create new sample realm clients:
  • sample-api type: bearer-only
  • sample-web type: public
  1. Create new client roles (for both clients):
  • PRODUCT_VIEWER
  • PRODUCT_MAINTAINER
  1. Assign role mappings for user john with recently created client roles
  2. Start springboot app on port 8070
rm -fr target ; mvn clean package
java -jar target/springboot-open-id-connect-sample-1.0-SNAPSHOT.jar

TEST w/ postman:
springboot2+spring_security+keycloak.postman_collection.json

Acquire access token:


Create a new product:


Retrieve all products:

API-DOCS (springdoc-openapi)

http://localhost:8070/api-docs (json)
http://localhost:8070/api-docs.yaml

REFERENCES:

https://github.com/thomasdarimont/awesome-keycloak https://docs.spring.io/spring-security/site/docs/current/reference/html5/
https://github.com/Baeldung/spring-security-oauth
https://www.baeldung.com/spring-security-oauth-jwt
https://github.com/hotire/spring-security-basic
https://stackoverflow.com/questions/58205510/spring-security-mapping-oauth2-claims-with-roles-to-secure-resource-server-endp
https://developers.redhat.com/blog/2020/01/29/api-login-and-jwt-token-generation-using-keycloak https://access.redhat.com/products/red-hat-single-sign-on https://www.baeldung.com/spring-rest-openapi-documentation

About

Springboot 2 OpenID Connect sample application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published