Skip to content

Commit d17f68c

Browse files
author
Ivan Franchin
committed
Project update
- use PasswordEncoderFactories.createDelegatingPasswordEncoder() instead of new BCryptPasswordEncoder(); - rename WebSecurityConfig to SecurityConfig; - remove public keyword from Beans; - replace ZonedDateTime with Instant; - update README.
1 parent ae22d50 commit d17f68c

File tree

13 files changed

+33
-53
lines changed

13 files changed

+33
-53
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
6060

6161
## Start Environment
6262

63-
- In a terminal, make sure you are inside `springboot-react-jwt-token` root folder;
63+
- In a terminal, make sure you are inside the `springboot-react-jwt-token` root folder;
6464

6565
- Run the following command to start docker compose containers:
6666
```
@@ -71,7 +71,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
7171

7272
- **order-api**
7373

74-
- Open a terminal and navigate to `springboot-react-jwt-token/order-api` folder;
74+
- Open a terminal and navigate to the `springboot-react-jwt-token/order-api` folder;
7575

7676
- Run the following `Maven` command to start the application:
7777
```
@@ -80,7 +80,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
8080
8181
- **order-ui**
8282
83-
- Open another terminal and navigate to `springboot-react-jwt-token/order-ui` folder;
83+
- Open another terminal and navigate to the `springboot-react-jwt-token/order-ui` folder;
8484
8585
- Run the command below if you are running the application for the first time:
8686
```
@@ -215,7 +215,7 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
215215
216216
- **Automatic Endpoints Test**
217217
218-
- Open a terminal and make sure you are in `springboot-react-jwt-token` root folder;
218+
- Open a terminal and make sure you are in the `springboot-react-jwt-token` root folder;
219219
220220
- Run the following script:
221221
```
@@ -274,14 +274,14 @@ On [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-C
274274
275275
- To stop `order-api` and `order-ui`, go to the terminals where they are running and press `Ctrl+C`;
276276
277-
- To stop and remove docker compose containers, network and volumes, go to a terminal and, inside: `springboot-react-jwt-token` root folder, run the command below
277+
- To stop and remove docker compose containers, network and volumes, go to a terminal and, inside the `springboot-react-jwt-token` root folder, run the command below:
278278
```
279279
docker compose down -v
280280
```
281281
282282
## How to upgrade order-ui dependencies to latest version
283283
284-
- In a terminal, make sure you are in `springboot-react-jwt-token/order-ui` folder;
284+
- In a terminal, make sure you are in the `springboot-react-jwt-token/order-ui` folder;
285285
286286
- Run the following commands:
287287
```

order-api/src/main/java/com/ivanfranchin/orderapi/config/ErrorAttributesConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
public class ErrorAttributesConfig {
1515

1616
@Bean
17-
public ErrorAttributes errorAttributes() {
17+
ErrorAttributes errorAttributes() {
1818
return new DefaultErrorAttributes() {
1919
@Override
2020
public Map<String, Object> getErrorAttributes(WebRequest webRequest, ErrorAttributeOptions options) {

order-api/src/main/java/com/ivanfranchin/orderapi/config/SwaggerConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class SwaggerConfig {
1515
private String applicationName;
1616

1717
@Bean
18-
public OpenAPI customOpenAPI() {
18+
OpenAPI customOpenAPI() {
1919
return new OpenAPI()
2020
.components(
2121
new Components().addSecuritySchemes(BEARER_KEY_SECURITY_SCHEME,

order-api/src/main/java/com/ivanfranchin/orderapi/model/Order.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import lombok.Data;
1111
import lombok.NoArgsConstructor;
1212

13-
import java.time.ZonedDateTime;
13+
import java.time.Instant;
1414

1515
@Data
1616
@NoArgsConstructor
@@ -27,14 +27,14 @@ public class Order {
2727
@JoinColumn(name = "user_id")
2828
private User user;
2929

30-
private ZonedDateTime createdAt;
30+
private Instant createdAt;
3131

3232
public Order(String description) {
3333
this.description = description;
3434
}
3535

3636
@PrePersist
3737
public void onPrePersist() {
38-
createdAt = ZonedDateTime.now();
38+
createdAt = Instant.now();
3939
}
4040
}

order-api/src/main/java/com/ivanfranchin/orderapi/rest/AuthController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.ivanfranchin.orderapi.rest.dto.LoginRequest;
77
import com.ivanfranchin.orderapi.rest.dto.SignUpRequest;
88
import com.ivanfranchin.orderapi.security.TokenProvider;
9-
import com.ivanfranchin.orderapi.security.WebSecurityConfig;
9+
import com.ivanfranchin.orderapi.security.SecurityConfig;
1010
import com.ivanfranchin.orderapi.service.UserService;
1111
import jakarta.validation.Valid;
1212
import lombok.RequiredArgsConstructor;
@@ -64,7 +64,7 @@ private User mapSignUpRequestToUser(SignUpRequest signUpRequest) {
6464
user.setPassword(passwordEncoder.encode(signUpRequest.getPassword()));
6565
user.setName(signUpRequest.getName());
6666
user.setEmail(signUpRequest.getEmail());
67-
user.setRole(WebSecurityConfig.USER);
67+
user.setRole(SecurityConfig.USER);
6868
return user;
6969
}
7070
}

order-api/src/main/java/com/ivanfranchin/orderapi/rest/dto/OrderDto.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.ivanfranchin.orderapi.rest.dto;
22

3-
import java.time.ZonedDateTime;
3+
import java.time.Instant;
44

5-
public record OrderDto(String id, String description, OrderDto.UserDto user, ZonedDateTime createdAt) {
5+
public record OrderDto(String id, String description, OrderDto.UserDto user, Instant createdAt) {
66

77
public record UserDto(String username) {
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.ivanfranchin.orderapi.rest.dto;
22

3-
import java.time.ZonedDateTime;
3+
import java.time.Instant;
44
import java.util.List;
55

66
public record UserDto(Long id, String username, String name, String email, String role, List<OrderDto> orders) {
77

8-
public record OrderDto(String id, String description, ZonedDateTime createdAt) {
8+
public record OrderDto(String id, String description, Instant createdAt) {
99
}
1010
}

order-api/src/main/java/com/ivanfranchin/orderapi/runner/DatabaseInitializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.ivanfranchin.orderapi.runner;
22

33
import com.ivanfranchin.orderapi.model.User;
4-
import com.ivanfranchin.orderapi.security.WebSecurityConfig;
4+
import com.ivanfranchin.orderapi.security.SecurityConfig;
55
import com.ivanfranchin.orderapi.service.UserService;
66
import lombok.RequiredArgsConstructor;
77
import lombok.extern.slf4j.Slf4j;
@@ -33,7 +33,7 @@ public void run(String... args) {
3333
}
3434

3535
private static final List<User> USERS = Arrays.asList(
36-
new User("admin", "admin", "Admin", "admin@mycompany.com", WebSecurityConfig.ADMIN),
37-
new User("user", "user", "User", "user@mycompany.com", WebSecurityConfig.USER)
36+
new User("admin", "admin", "Admin", "admin@mycompany.com", SecurityConfig.ADMIN),
37+
new User("user", "user", "User", "user@mycompany.com", SecurityConfig.USER)
3838
);
3939
}

order-api/src/main/java/com/ivanfranchin/orderapi/security/CorsConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class CorsConfig {
1414

1515
@Bean
16-
public CorsConfigurationSource corsConfigurationSource(@Value("${app.cors.allowed-origins}") List<String> allowedOrigins) {
16+
CorsConfigurationSource corsConfigurationSource(@Value("${app.cors.allowed-origins}") List<String> allowedOrigins) {
1717
CorsConfiguration configuration = new CorsConfiguration();
1818
configuration.setAllowCredentials(true);
1919
configuration.setAllowedOrigins(allowedOrigins);

order-api/src/main/java/com/ivanfranchin/orderapi/security/CustomUserDetails.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,4 @@ public class CustomUserDetails implements UserDetails {
1515
private String name;
1616
private String email;
1717
private Collection<? extends GrantedAuthority> authorities;
18-
19-
@Override
20-
public boolean isAccountNonExpired() {
21-
return true;
22-
}
23-
24-
@Override
25-
public boolean isAccountNonLocked() {
26-
return true;
27-
}
28-
29-
@Override
30-
public boolean isCredentialsNonExpired() {
31-
return true;
32-
}
33-
34-
@Override
35-
public boolean isEnabled() {
36-
return true;
37-
}
3818
}

0 commit comments

Comments
 (0)