Skip to content

Commit 1be71b8

Browse files
authored
Merge pull request #99 from opticSquid/fix/add-same-site
Adds domain to cookie
2 parents 337ddf7 + cd157c7 commit 1be71b8

File tree

7 files changed

+19
-6
lines changed

7 files changed

+19
-6
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ FROM amazoncorretto:21-alpine
1212

1313
WORKDIR /app
1414

15-
COPY --from=builder /usr/src/app/target/hangout-auth-api-2.3.3.jar .
15+
COPY --from=builder /usr/src/app/target/hangout-auth-api-2.3.4.jar .
1616

17-
CMD ["java", "-jar", "hangout-auth-api-2.3.3.jar"]
17+
CMD ["java", "-jar", "hangout-auth-api-2.3.4.jar"]

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</parent>
1313
<groupId>com.hangout.core</groupId>
1414
<artifactId>hangout-auth-api</artifactId>
15-
<version>2.3.3</version>
15+
<version>2.3.4</version>
1616
<name>hangout-auth-api</name>
1717
<description>Microservice for authentication and authorization of users in Hangout</description>
1818
<properties>

src/main/java/com/hangout/core/auth_api/config/SecurityConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ CorsConfigurationSource myCorsConfigurationSource() {
9898
.name()));
9999
internalServiceConfiguration
100100
.setAllowedMethods(Arrays.asList(HttpMethod.OPTIONS.name(), HttpMethod.POST.name()));
101-
clientConfiguration.setAllowCredentials(false);
101+
clientConfiguration.setAllowCredentials(true);
102102
internalServiceConfiguration.setAllowCredentials(false);
103103
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
104104
source.setCorsConfigurations(Map.of(

src/main/java/com/hangout/core/auth_api/controller/AuthController.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.beans.factory.annotation.Qualifier;
8+
import org.springframework.beans.factory.annotation.Value;
89
import org.springframework.http.HttpHeaders;
910
import org.springframework.http.HttpStatus;
1011
import org.springframework.http.ResponseCookie;
@@ -44,6 +45,8 @@
4445
@RequiredArgsConstructor
4546
@Slf4j
4647
public class AuthController {
48+
@Value("${hangout.cookie.domain}")
49+
private String cookieDomain;
4750
@Autowired
4851
private UserDetailsServiceImpl userDetailsService;
4952
@Autowired
@@ -136,7 +139,8 @@ private ResponseCookie createCookie(String refreshToken) {
136139
ResponseCookie cookie = ResponseCookie.from(Constants.REFRESH_TOKEN, refreshToken)
137140
.maxAge(calculateMaxAgeFromDate(refreshTokenUtil.getExpiresAt(refreshToken)))
138141
.httpOnly(true)
139-
.sameSite("Strict")
142+
.sameSite("SameSite")
143+
.domain(cookieDomain)
140144
.path("/auth-api/v1/auth/renew")
141145
.build();
142146
return cookie;

src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
"name": "hangout.client.origin",
6565
"type": "java.lang.String",
6666
"description": "The comma separated list of the origins of the list of user facing clients"
67+
},
68+
{
69+
"name": "hangout.cookie.domain",
70+
"type": "java.lang.String",
71+
"description": "Domain for the generated cookie"
6772
}
6873
]
6974
}

src/main/resources/application-home.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ hangout:
3737
secret: kTYpg95oeqgnBhfi16DYSe2NT2T6kXPDKGrLeXpSA2rc7Jltt32AtYGPdmsYFoKt0H2_dJj8RPgbP3UGzD6ONSDJOWbbMvSU1MyNDM2xj5ncv2oN1iewNXz6gEyTdeuR3IolmGnPBPFVZR78is6MnS7W7WBpRvQCoaes9l7GhMHf6MhtX4nstm9LkTUx5-MQw4Tg5XTgo82FApVcg1x9hvDno6WTci_gJ9874xsAi5wg9V15cXFTesJ3GJfGf4NTkX9SqqAVG_D08oLOXFAXjvLDYVrl_O_9JMyCBgVEyMV81UMw8v72nYGAfDPy2uH3nTUOTXA4qlijAXOFGxV7kg
3838
long-term-expiry: 604800000 # 7 daya
3939
short-term-expiry: 600000 # 10 mins
40+
cookie:
41+
domain: localhost
4042
notification-service:
4143
url: http://localhost:5012
4244
ip-api:
4345
url: http://ip-api.com
4446
internal-services:
4547
origin: http://localhost:5012, http://localhost:5013
4648
client:
47-
origin: http://localhost:3000
49+
origin: http://localhost:5173

src/main/resources/application.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ hangout:
8383
secret: ${REFRESH_TOKEN_SECRET}
8484
long-term-expiry: ${REFRESH_TOKEN_LONG_TERM_EXPIRY}
8585
short-term-expiry: ${REFRESH_TOKEN_SHORT_TERM_EXPIRY}
86+
cookie:
87+
domain: ${COOKIE_DOMAIN}
8688
notification-service:
8789
url: ${NOTIFICATION_SERVICE}
8890
ip-api:

0 commit comments

Comments
 (0)