Skip to content

Commit 9b871a9

Browse files
committed
Update cookie settings in SocialAuthController and session configuration for enhanced security
This commit modifies the cookie settings in the SocialAuthController to use 'none' for the SameSite attribute, allowing cross-site cookie usage. Additionally, it updates the session configuration to set the secure cookie option to true and changes the SameSite setting to be environment variable driven, improving security and flexibility in cookie handling.
1 parent bdd8dc2 commit 9b871a9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/Http/Controllers/Auth/SocialAuthController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ public function handleGoogleCallback(): RedirectResponse
6060

6161
return redirect("{$frontendUrl}/auth/callback")->cookie('accessToken', $accessToken,
6262
Carbon::now()->addMinutes(config('passport.token_ttl'))->timestamp,
63-
'/', $domain, $secure, true, false, 'lax') // ttl, path, domain, secure, httpOnly, raw, sameSite
63+
'/', $domain, $secure, true, false, 'none') // ttl, path, domain, secure, httpOnly, raw, sameSite
6464
->cookie('refreshToken', $refreshToken,
6565
Carbon::now()->addDays(30)->timestamp, // Longue durée de vie
66-
'/', $domain, $secure, true, false, 'lax');
66+
'/', $domain, $secure, true, false, 'none');
6767
}
6868

6969
protected function getUserScope(int $roleId): string

config/session.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
|
169169
*/
170170
'http_only' => true, // Activer le cookie HTTP only
171-
'secure' => env('SESSION_SECURE_COOKIE',false),
171+
'secure' => env('SESSION_SECURE_COOKIE',true),
172172

173173
/*
174174
|--------------------------------------------------------------------------
@@ -196,7 +196,7 @@
196196
|
197197
*/
198198

199-
'same_site' => 'lax',
199+
'same_site' => env('SESSION_SAME_SITE', 'none'),
200200

201201
/*
202202
|--------------------------------------------------------------------------

0 commit comments

Comments
 (0)