File tree Expand file tree Collapse file tree 4 files changed +25
-17
lines changed Expand file tree Collapse file tree 4 files changed +25
-17
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,10 @@ return [
3939 | Enable or disable CloudFront signed cookies. When disabled, cookies will
4040 | not be set even if the middleware is active.
4141 |
42- | Default: true
42+ | Default: false
4343 |
4444 */
45- 'enabled' => env('CLOUDFRONT_ENABLED', true ),
45+ 'enabled' => env('CLOUDFRONT_ENABLED', false ),
4646
4747 /*
4848 |--------------------------------------------------------------------------
Original file line number Diff line number Diff line change 99 | Enable or disable CloudFront signed cookies. When disabled, cookies will
1010 | not be set even if the middleware is active.
1111 |
12- | Default: true
12+ | Default: false
1313 |
1414 */
15- 'enabled ' => env ('CLOUDFRONT_ENABLED ' , true ),
15+ 'enabled ' => env ('CLOUDFRONT_ENABLED ' , false ),
1616
1717 /*
1818 |--------------------------------------------------------------------------
Original file line number Diff line number Diff line change 99
1010class Config
1111{
12+ public static function isEnabled (): bool
13+ {
14+ $ enabled = config ('cloudfront-cookies.enabled ' );
15+
16+ if ($ enabled === true ) {
17+ return true ;
18+ }
19+
20+ if (trim ($ enabled ) === 'true ' ) {
21+ return true ;
22+ }
23+
24+ if (trim ($ enabled ) === '1 ' ) {
25+ return true ;
26+ }
27+
28+ return false ;
29+ }
30+
1231 public static function getVersion (): string
1332 {
1433 return config ('cloudfront-cookies.version ' ) ?? 'latest ' ;
@@ -78,17 +97,6 @@ public static function getCookieDuration(): int
7897 return (int ) self ::getExpirationInterval ()->totalMinutes ;
7998 }
8099
81- public static function isEnabled (): bool
82- {
83- $ enabled = config ('cloudfront-cookies.enabled ' );
84-
85- if ($ enabled === null ) {
86- return true ;
87- }
88-
89- return (bool ) $ enabled ;
90- }
91-
92100 public static function getGuard (): ?string
93101 {
94102 return config ('cloudfront-cookies.guard ' );
Original file line number Diff line number Diff line change 115115 expect (Config::isEnabled ())->toBe (false );
116116 });
117117
118- it ('returns true by default when not configured ' , function () {
118+ it ('returns false by default when not configured ' , function () {
119119 config ()->set ('cloudfront-cookies.enabled ' , null );
120120
121- expect (Config::isEnabled ())->toBe (true );
121+ expect (Config::isEnabled ())->toBe (false );
122122 });
123123});
124124
You can’t perform that action at this time.
0 commit comments