Skip to content

Commit 7ff14e6

Browse files
committed
refactor: prod
1 parent 76a5ad3 commit 7ff14e6

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

src/main/java/com/joaov1ct0r/restful_api_users_java/modules/auth/controllers/SignInController.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,12 @@ public ResponseEntity<Object> handle(
6969
var userCookie = this.createCookieService.execute(
7070
"user",
7171
payload.getUserId(),
72-
"localhost"
73-
// "crud.shop"
72+
"crud.shop"
7473
);
7574
var authorizationCookie = this.createCookieService.execute(
7675
"authorization",
7776
token,
78-
"localhost"
79-
// "crud.shop"
77+
"crud.shop"
8078
);
8179

8280
response.addCookie(userCookie);

src/main/java/com/joaov1ct0r/restful_api_users_java/modules/auth/services/CreateCookieService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ public Cookie execute(String cookieName, String cookieValue, String domain) {
1010
int twoDaysInSeconds = 2 * 24 * 60 * 60; // 2 dias em segundos
1111
var cookie = new Cookie(cookieName, cookieValue);
1212
cookie.setDomain(domain);
13-
cookie.setHttpOnly(false);
14-
// cookie.setHttpOnly(true);
13+
cookie.setHttpOnly(true);
1514
cookie.setPath("/");
16-
cookie.setSecure(false);
17-
// cookie.setSecure(true);
15+
cookie.setSecure(true);
1816
cookie.setMaxAge(twoDaysInSeconds);
1917

2018
return cookie;

src/main/java/com/joaov1ct0r/restful_api_users_java/security/CorsConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public CorsFilter corsFilter() {
1515
CorsConfiguration config = new CorsConfiguration();
1616
config.setAllowCredentials(true);
1717
config.addAllowedOrigin("https://crud.shop");
18-
config.addAllowedOrigin("http://localhost:3000");
1918
config.addAllowedHeader("*");
2019
config.addAllowedMethod("*");
2120
source.registerCorsConfiguration("/**", config);

src/main/java/com/joaov1ct0r/restful_api_users_java/security/WebConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public WebMvcConfigurer corsConfigurer() {
1414
@Override
1515
public void addCorsMappings(CorsRegistry registry) {
1616
registry.addMapping("/**") // Aplica CORS a todos os endpoints
17-
.allowedOrigins("https://crud.shop", "http://localhost:3000") // Define a origem permitida
17+
.allowedOrigins("https://crud.shop") // Define a origem permitida
1818
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // Define os métodos HTTP permitidos
1919
.allowCredentials(true); // Permite o envio de cookies
2020
}

0 commit comments

Comments
 (0)