Skip to content

Commit

Permalink
Optimize the introduction and installation docs (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-doehring authored Jul 31, 2021
1 parent eb67c72 commit f8d7149
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,37 @@ dogado Cookie Manager for Laravel

1. [Introduction](#introduction)
1. [Requirements](#requirements)
1. [Steps to configure](#steps-to-configure)
- [Checkout](#checkout)
- [Load Class into your config](#load-class-into-your-config)
1. [Installation](#installation)
- [Configure your Kernel to use the middleware](#configure-your-kernel-to-use-the-middleware)

<!-- /TOC -->

## Introduction

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 f8d7149

Please sign in to comment.