|
| 1 | +# Spring Boot Refresh Token with JWT example |
| 2 | + |
| 3 | +Build JWT Refresh Token in the Java Spring Boot Application. You can know how to expire the JWT, then renew the Access Token with Refresh Token. |
| 4 | + |
| 5 | +The instruction can be found at: |
| 6 | +[Spring Boot Refresh Token with JWT example](https://bezkoder.com/spring-boot-refresh-token-jwt/) |
| 7 | + |
| 8 | +## User Registration, User Login and Authorization process. |
| 9 | +The diagram shows flow of how we implement User Registration, User Login and Authorization process. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +And this is for Refresh Token: |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +## Spring Boot Server Architecture with Spring Security |
| 18 | +You can have an overview of our Spring Boot Server with the diagram below: |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +Related Posts: |
| 23 | +> [Spring Boot, Spring Security, MySQL: JWT Authentication & Authorization example](https://bezkoder.com/spring-boot-jwt-authentication/) |
| 24 | +
|
| 25 | +> [For PostgreSQL](https://bezkoder.com/spring-boot-security-postgresql-jwt-authentication/) |
| 26 | +
|
| 27 | +> [For MongoDB](https://bezkoder.com/spring-boot-jwt-auth-mongodb/) |
| 28 | +
|
| 29 | +## Fullstack Authentication |
| 30 | + |
| 31 | +> [Spring Boot + Vue.js JWT Authentication](https://bezkoder.com/spring-boot-vue-js-authentication-jwt-spring-security/) |
| 32 | +
|
| 33 | +> [Spring Boot + Angular 8 JWT Authentication](https://bezkoder.com/angular-spring-boot-jwt-auth/) |
| 34 | +
|
| 35 | +> [Spring Boot + Angular 10 JWT Authentication](https://bezkoder.com/angular-10-spring-boot-jwt-auth/) |
| 36 | +
|
| 37 | +> [Spring Boot + Angular 11 JWT Authentication](https://bezkoder.com/angular-11-spring-boot-jwt-auth/) |
| 38 | +
|
| 39 | +> [Spring Boot + React JWT Authentication](https://bezkoder.com/spring-boot-react-jwt-auth/) |
| 40 | +
|
| 41 | +## Fullstack CRUD App |
| 42 | + |
| 43 | +> [Vue.js + Spring Boot + MySQL/PostgreSQL example](https://bezkoder.com/spring-boot-vue-js-crud-example/) |
| 44 | +
|
| 45 | +> [Angular 8 + Spring Boot + MySQL example](https://bezkoder.com/angular-spring-boot-crud/) |
| 46 | +
|
| 47 | +> [Angular 8 + Spring Boot + PostgreSQL example](https://bezkoder.com/angular-spring-boot-postgresql/) |
| 48 | +
|
| 49 | +> [Angular 10 + Spring Boot + MySQL example](https://bezkoder.com/angular-10-spring-boot-crud/) |
| 50 | +
|
| 51 | +> [Angular 10 + Spring Boot + PostgreSQL example](https://bezkoder.com/angular-10-spring-boot-postgresql/) |
| 52 | +
|
| 53 | +> [Angular 11 + Spring Boot + MySQL example](https://bezkoder.com/angular-11-spring-boot-crud/) |
| 54 | +
|
| 55 | +> [Angular 11 + Spring Boot + PostgreSQL example](https://bezkoder.com/angular-11-spring-boot-postgresql/) |
| 56 | +
|
| 57 | +> [React + Spring Boot + MySQL example](https://bezkoder.com/react-spring-boot-crud/) |
| 58 | +
|
| 59 | +> [React + Spring Boot + PostgreSQL example](https://bezkoder.com/spring-boot-react-postgresql/) |
| 60 | +
|
| 61 | +> [React + Spring Boot + MongoDB example](https://bezkoder.com/react-spring-boot-mongodb/) |
| 62 | +
|
| 63 | +Run both Back-end & Front-end in one place: |
| 64 | +> [Integrate Angular with Spring Boot Rest API](https://bezkoder.com/integrate-angular-spring-boot/) |
| 65 | +
|
| 66 | +> [Integrate React.js with Spring Boot Rest API](https://bezkoder.com/integrate-reactjs-spring-boot/) |
| 67 | +
|
| 68 | +> [Integrate Vue.js with Spring Boot Rest API](https://bezkoder.com/integrate-vue-spring-boot/) |
| 69 | +
|
| 70 | +## More Practice: |
| 71 | +> [Spring Boot File upload example with Multipart File](https://bezkoder.com/spring-boot-file-upload/) |
| 72 | +
|
| 73 | +> [Exception handling: @RestControllerAdvice example in Spring Boot](https://bezkoder.com/spring-boot-restcontrolleradvice/) |
| 74 | +
|
| 75 | +> [Spring Boot Repository Unit Test with @DataJpaTest](https://bezkoder.com/spring-boot-unit-test-jpa-repo-datajpatest/) |
| 76 | +
|
| 77 | +> [Deploy Spring Boot App on AWS – Elastic Beanstalk](https://bezkoder.com/deploy-spring-boot-aws-eb/) |
| 78 | +
|
| 79 | +> [Secure Spring Boot App with Spring Security & JWT Authentication](https://bezkoder.com/spring-boot-jwt-authentication/) |
| 80 | +
|
| 81 | +## Dependency |
| 82 | +```xml |
| 83 | +<dependency> |
| 84 | + <groupId>org.springframework.boot</groupId> |
| 85 | + <artifactId>spring-boot-starter-data-jpa</artifactId> |
| 86 | +</dependency> |
| 87 | + |
| 88 | +<dependency> |
| 89 | + <groupId>org.springframework.boot</groupId> |
| 90 | + <artifactId>spring-boot-starter-security</artifactId> |
| 91 | +</dependency> |
| 92 | + |
| 93 | +<dependency> |
| 94 | + <groupId>org.springframework.boot</groupId> |
| 95 | + <artifactId>spring-boot-starter-web</artifactId> |
| 96 | +</dependency> |
| 97 | + |
| 98 | +<dependency> |
| 99 | + <groupId>mysql</groupId> |
| 100 | + <artifactId>mysql-connector-java</artifactId> |
| 101 | + <scope>runtime</scope> |
| 102 | +</dependency> |
| 103 | + |
| 104 | +<dependency> |
| 105 | + <groupId>io.jsonwebtoken</groupId> |
| 106 | + <artifactId>jjwt</artifactId> |
| 107 | + <version>0.9.1</version> |
| 108 | +</dependency> |
| 109 | +``` |
| 110 | + |
| 111 | +## Configure Spring Datasource, JPA, App properties |
| 112 | +Open `src/main/resources/application.properties` |
| 113 | + |
| 114 | +```properties |
| 115 | +spring.datasource.url= jdbc:mysql://localhost:3306/testdb?useSSL=false |
| 116 | +spring.datasource.username= root |
| 117 | +spring.datasource.password= 123456 |
| 118 | + |
| 119 | +spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5InnoDBDialect |
| 120 | +spring.jpa.hibernate.ddl-auto= update |
| 121 | + |
| 122 | +# App Properties |
| 123 | +bezkoder.app.jwtSecret= bezKoderSecretKey |
| 124 | +bezkoder.app.jwtExpirationMs= 3600000 |
| 125 | +bezkoder.app.jwtRefreshExpirationMs= 86400000 |
| 126 | +``` |
| 127 | + |
| 128 | +## Run Spring Boot application |
| 129 | +``` |
| 130 | +mvn spring-boot:run |
| 131 | +``` |
| 132 | + |
| 133 | +## Run following SQL insert statements |
| 134 | +``` |
| 135 | +INSERT INTO roles(name) VALUES('ROLE_USER'); |
| 136 | +INSERT INTO roles(name) VALUES('ROLE_MODERATOR'); |
| 137 | +INSERT INTO roles(name) VALUES('ROLE_ADMIN'); |
| 138 | +``` |
0 commit comments