Skip to content
/ spring-react Public template

Template project that integrates Spring Boot, Spring Security, React, and React OIDC Context.

License

Notifications You must be signed in to change notification settings

yo1000/spring-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring React

How to run

for Keycloak

docker compose up
./mvnw spring-boot:run -Dspring-boot.run.jvmArguments='
-Dserver.error.whitelabel.enabled=true
-Dspring.security.oauth2.resourceserver.jwt.issuer-uri=https://localhost:8000/realms/master
-Dapp.security.idp=keycloak
-Dapp.security.cors.allowed-origins=https://localhost:3000
-Dapp.frontend.oidc.authority=https://localhost:8000
-Dapp.frontend.oidc.redirectUri=https://localhost:8080
-Dapp.frontend.oidc.clientId=spring-react
-Dapp.frontend.oidc.authorizationEndpoint=${authority}/realms/master/protocol/openid-connect/auth
-Dapp.frontend.oidc.tokenEndpoint=${authority}/realms/master/protocol/openid-connect/token
-Dapp.frontend.oidc.userinfoEndpoint=${authority}/realms/master/protocol/openid-connect/userinfo
-Dapp.frontend.oidc.signoutUri=${authority}/realms/master/protocol/openid-connect/logout?client_id=${clientId}&post_logout_redirect_uri=${redirectUri}&id_token_hint=${idToken}
'
(cd src/main/resources/frontend && \
NODE_ENV=development \
IDP=keycloak \
PORT=3000 \
API_BASE_URI=https://localhost:8080 \
npx webpack serve)

for Cognito

Setup cognito

  1. Create user pool
  2. Create user
  3. Create group naming as "admin", and assign user to created group

Following, replace variables in double brackets.

./mvnw spring-boot:run -Dspring-boot.run.jvmArguments='
-Dserver.error.whitelabel.enabled=true
-Dspring.security.oauth2.resourceserver.jwt.issuer-uri=https://cognito-idp.ap-northeast-1.amazonaws.com/{{cognito-user-pool-id}}
-Dapp.security.idp=cognito
-Dapp.security.cors.allowed-origins=https://localhost:3000
-Dapp.frontend.oidc.authority=https://{{cognito-subdomain}}.auth.{{cognito-region}}.amazoncognito.com
-Dapp.frontend.oidc.redirectUri=https://localhost:8080
-Dapp.frontend.oidc.clientId={{cognito-client-id:abcdefghijklmnopqrstuvwxyz}}
-Dapp.frontend.oidc.authorizationEndpoint=${authority}/oauth2/authorize
-Dapp.frontend.oidc.tokenEndpoint=${authority}/oauth2/token
-Dapp.frontend.oidc.userinfoEndpoint=${authority}/oauth2/userInfo
-Dapp.frontend.oidc.signoutUri=${authority}/logout?client_id=${clientId}&logout_uri=${redirectUri}
'

Following, replace variables in double brackets.

(cd src/main/resources/frontend && \
NODE_ENV=development \
IDP=cognito \
PORT=3000 \
API_BASE_URI=https://localhost:8080 \
npx webpack serve)

Project structure

  • (B): Backend
  • (F): Frontend
  • (*): Others
/ ...................................... (*) Project root
|_ src/
|   |_ main/
|       |_ java/ ....................... (B) Backend root
|       |   |_ (...)/
|       |       |_ config/ ............. (B) Configuration
|       |       |_ domain/ ............. (B) Domain
|       |       |_ infrastructure/ ..... (B) Persistence
|       |       |_ presentation/ ....... (B) Controller
|       |
|       |_ resources/
|           |_ frontend/ ............... (F) Frontend root
|           |   |_ src/
|           |   |   |_ clients/ ........ (F) API clients
|           |   |   |_ components/ ..... (F) Screen parts
|           |   |   |_ pages/ .......... (F) Screen
|           |   |   |_ App,js .......... (F) Routing
|           |   |   |_ index.js ........ (F) JS root
|           |   |
|           |   |_ public/
|           |   |   |_ index.html ...... (F) HTML root
|           |   |
|           |   |_ package.json ........ (F) Node.JS build config
|           |   |_ webpack.config.js ... (F) Webpack build config
|           |
|           |_ application.yml ......... (B) Spring Boot config file
|           |_ schema.sql .............. (B) Development database setup file
|
|_ compose.yml ......................... (*) IDP and others
|_ keycloak-setup.sh ................... (*) IDP setup script
|_ pom.xml ............................. (B) Java build config

About

Template project that integrates Spring Boot, Spring Security, React, and React OIDC Context.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published