Skip to content

Commit

Permalink
docs: optimize the README file
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-doehring committed Jul 31, 2021
1 parent eb67c72 commit f3c7e83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,28 @@ dogado Cookie Manager for Laravel

A client library package for Laravel based projects, maintained by the [dogado GmbH](https://dogado.de).

It provides a middleware class that automatically transforms cookies to be
[`Secure`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) if the request is SSL
encrypted and, if the browser supports it, sets the
[`SameSite=None`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite) attribute.

To learn more about `SameSite` cookies and how to use them, check out the
[web.dev blog from Google](https://web.dev/samesite-cookies-explained/) or the
[Mozilla docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite).

## Requirements
* php `^7.3` or `^8.0`
* `symfony/http-foundation` version `^4.4` or `^5.0`

## Steps to configure
## Installation

### Checkout
Include this package into the project:
```
composer require dogado/laravel-cookie-manager
```

### Add the laravel middleware to your kernel
Add the following class according to your needs to the appropriate Laravel kernel middleware configuration.
### Configure your Kernel to use the middleware

Add the following class to the appropriate Laravel kernel middleware configuration according to your requirements.
```
\Dogado\Laravel\CookieManager\Http\Middleware\SecureResponseCookies::class
```
Expand Down
8 changes: 4 additions & 4 deletions src/Policies/BrowserPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ public function canHaveAttributeSameSite(): bool
{
switch ($this->browser->getBrowser()) {
case Browser::BROWSER_CHROME:
return $this->browserVersionGreaterThen(51);
return $this->browserVersionGreaterThan(51);
case Browser::BROWSER_FIREFOX:
return $this->browserVersionGreaterThen(60);
return $this->browserVersionGreaterThan(60);
case Browser::BROWSER_OPERA:
return $this->browserVersionGreaterThen(39);
return $this->browserVersionGreaterThan(39);
default:
return false;
}
}

private function browserVersionGreaterThen(int $versionToCheck): bool
private function browserVersionGreaterThan(int $versionToCheck): bool
{
$matches = null;
if (!preg_match('/^(?<mainVersion>\d+)/', $this->browser->getVersion(), $matches)) {
Expand Down

0 comments on commit f3c7e83

Please sign in to comment.