1
1
# Spring Boot Login example with Spring Security, MySQL and JWT
2
+ Build a Spring Boot Login and Registration example (Rest API) that supports JWT with HttpOnly Cookie. You’ll know:
2
3
3
- - Appropriate Flow for User Login and Registration with JWT
4
+ - Appropriate Flow for User Login and Registration with JWT and HttpOnly Cookies
4
5
- Spring Boot Rest Api Architecture with Spring Security
5
6
- How to configure Spring Security to work with JWT
6
7
- How to define Data Models and association for Authentication and Authorization
@@ -22,6 +23,11 @@ For more detail, please visit:
22
23
23
24
> [ For MongoDB] ( https://www.bezkoder.com/spring-boot-jwt-auth-mongodb/ )
24
25
26
+ Working with Front-end:
27
+ > [ Angular 12] ( https://www.bezkoder.com/angular-12-jwt-auth-httponly-cookie/ ) / [ Angular 13] ( https://www.bezkoder.com/angular-13-jwt-auth-httponly-cookie/ ) / [ Angular 14] ( https://www.bezkoder.com/angular-14-jwt-auth/ ) / [ Angular 15] ( https://www.bezkoder.com/angular-15-jwt-auth/ ) / [ Angular 16] ( https://www.bezkoder.com/angular-16-jwt-auth/ )
28
+
29
+ > [ React] ( https://www.bezkoder.com/react-login-example-jwt-hooks/ ) / [ React Redux] ( https://www.bezkoder.com/redux-toolkit-auth/ )
30
+
25
31
## Dependency
26
32
– If you want to use PostgreSQL:
27
33
``` xml
@@ -34,8 +40,8 @@ For more detail, please visit:
34
40
– or MySQL:
35
41
``` xml
36
42
<dependency >
37
- <groupId >mysql</groupId >
38
- <artifactId >mysql-connector-java </artifactId >
43
+ <groupId >com. mysql</groupId >
44
+ <artifactId >mysql-connector-j </artifactId >
39
45
<scope >runtime</scope >
40
46
</dependency >
41
47
```
@@ -54,7 +60,8 @@ spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
54
60
spring.jpa.hibernate.ddl-auto= update
55
61
56
62
# App Properties
57
- bezkoder.app.jwtSecret= bezKoderSecretKey
63
+ bezkoder.app.jwtCookieName= bezkoder
64
+ bezkoder.app.jwtSecret= ======================BezKoder=Spring===========================
58
65
bezkoder.app.jwtExpirationMs= 86400000
59
66
```
60
67
- For MySQL
@@ -67,7 +74,8 @@ spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5InnoDBDiale
67
74
spring.jpa.hibernate.ddl-auto= update
68
75
69
76
# App Properties
70
- bezkoder.app.jwtSecret= bezKoderSecretKey
77
+ bezkoder.app.jwtCookieName= bezkoder
78
+ bezkoder.app.jwtSecret= ======================BezKoder=Spring===========================
71
79
bezkoder.app.jwtExpirationMs= 86400000
72
80
```
73
81
## Run Spring Boot application
@@ -93,14 +101,22 @@ INSERT INTO roles(name) VALUES('ROLE_ADMIN');
93
101
94
102
> [ Spring Boot Repository Unit Test with @DataJpaTest ] ( https://bezkoder.com/spring-boot-unit-test-jpa-repo-datajpatest/ )
95
103
104
+ > [ Spring Boot Rest Controller Unit Test with @WebMvcTest ] ( https://www.bezkoder.com/spring-boot-webmvctest/ )
105
+
96
106
> [ Spring Boot Pagination & Sorting example] ( https://www.bezkoder.com/spring-boot-pagination-sorting-example/ )
97
107
108
+ > Validation: [ Spring Boot Validate Request Body] ( https://www.bezkoder.com/spring-boot-validate-request-body/ )
109
+
110
+ > Documentation: [ Spring Boot and Swagger 3 example] ( https://www.bezkoder.com/spring-boot-swagger-3/ )
111
+
112
+ > Caching: [ Spring Boot Redis Cache example] ( https://www.bezkoder.com/spring-boot-redis-cache-example/ )
113
+
98
114
Associations:
99
- > [ Spring Boot One To Many example with Spring JPA, Hibernate ] ( https://www.bezkoder.com/jpa-one-to-many/ )
115
+ > [ JPA/Hibernate One To Many example in Spring Boot ] ( https://www.bezkoder.com/jpa-one-to-many/ )
100
116
101
- > [ Spring Boot Many To Many example with Spring JPA, Hibernate ] ( https://www.bezkoder.com/jpa-many-to-many/ )
117
+ > [ JPA/Hibernate Many To Many example in Spring Boot ] ( https://www.bezkoder.com/jpa-many-to-many/ )
102
118
103
- > [ JPA One To One example with Spring Boot] ( https://www.bezkoder.com/jpa-one-to-one/ )
119
+ > [ JPA/Hibernate One To One example in Spring Boot] ( https://www.bezkoder.com/jpa-one-to-one/ )
104
120
105
121
Deployment:
106
122
> [ Deploy Spring Boot App on AWS – Elastic Beanstalk] ( https://www.bezkoder.com/deploy-spring-boot-aws-eb/ )
@@ -147,6 +163,18 @@ Deployment:
147
163
148
164
> [ Angular 14 + Spring Boot + PostgreSQL example] ( https://www.bezkoder.com/spring-boot-angular-14-postgresql/ )
149
165
166
+ > [ Angular 15 + Spring Boot + H2 Embedded Database example] ( https://www.bezkoder.com/spring-boot-angular-15-crud/ )
167
+
168
+ > [ Angular 15 + Spring Boot + MySQL example] ( https://www.bezkoder.com/spring-boot-angular-15-mysql/ )
169
+
170
+ > [ Angular 15 + Spring Boot + PostgreSQL example] ( https://www.bezkoder.com/spring-boot-angular-15-postgresql/ )
171
+
172
+ > [ Angular 16 + Spring Boot + H2 Embedded Database example] ( https://www.bezkoder.com/spring-boot-angular-16-crud/ )
173
+
174
+ > [ Angular 16 + Spring Boot + MySQL example] ( https://www.bezkoder.com/spring-boot-angular-16-mysql/ )
175
+
176
+ > [ Angular 16 + Spring Boot + PostgreSQL example] ( https://www.bezkoder.com/spring-boot-angular-16-postgresql/ )
177
+
150
178
> [ React + Spring Boot + MySQL example] ( https://www.bezkoder.com/react-spring-boot-crud/ )
151
179
152
180
> [ React + Spring Boot + PostgreSQL example] ( https://www.bezkoder.com/spring-boot-react-postgresql/ )
0 commit comments