2017 © Pedro Peláez
 

library https

Middleware to redirect to https and adds the Strict-Transport-Security header

image

middlewares/https

Middleware to redirect to https and adds the Strict-Transport-Security header

  • Sunday, March 11, 2018
  • by oscarotero
  • Repository
  • 2 Watchers
  • 4 Stars
  • 1,400 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 9 Versions
  • 34 % Grown

The README.md

middlewares/https

Latest Version on Packagist ![Software License][ico-license] Testing ![Total Downloads][ico-downloads], (*1)

Middleware to redirect to https if the request is http and add the Strict Transport Security header to protect against protocol downgrade attacks and cookie hijacking., (*2)

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/https., (*3)

composer require middlewares/https

Example

$dispatcher = new Dispatcher([
    (new Middlewares\Https())
        ->includeSubdomains()
]);

$response = $dispatcher->dispatch(new ServerRequest());

Usage

This middleware accept a Psr\Http\Message\ResponseFactoryInterface as a constructor argument, to create the redirect responses. If it's not defined, Middleware\Utils\Factory will be used to detect it automatically., (*4)

$responseFactory = new MyOwnResponseFactory();

//Detect the response factory automatically
$https = new Middlewares\Https();

//Use a specific factory
$htts = new Middlewares\Https($responseFactory);

maxAge

This option allow to define the value of max-age directive for the Strict-Transport-Security header. By default is 31536000 (1 year)., (*5)

$threeYears = 31536000 * 3;

$https = (new Middlewares\Https())->maxAge($threeYears);

includeSubdomains

By default, the includeSubDomains directive is not included in the Strict-Transport-Security header. Use this function to change this behavior., (*6)

$https = (new Middlewares\Https())->includeSubdomains();

preload

By default, the preload directive is not included in the Strict-Transport-Security header. Use this function to change this behavior., (*7)

$https = (new Middlewares\Https())->preload();

checkHttpsForward

Enabling this option ignore requests containing the header X-Forwarded-Proto: https or X-Forwarded-Port: 443. This is specially useful if the site is behind a https load balancer., (*8)

$https = (new Middlewares\Https())->checkHttpsForward();

redirect

This option returns a redirection response from http to https. It's enabled by default., (*9)

//Disable redirections
$https = (new Middlewares\Https())->redirect(false);

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details., (*10)

The MIT License (MIT). Please see LICENSE for more information., (*11)

The Versions

11/03 2018

dev-master

9999999-dev https://github.com/middlewares/https

Middleware to redirect to https and adds the Strict-Transport-Security header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 https http psr-15 strict-transport-security

11/03 2018

v1.1.0

1.1.0.0 https://github.com/middlewares/https

Middleware to redirect to https and adds the Strict-Transport-Security header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 https http psr-15 strict-transport-security

26/01 2018

v1.0.0

1.0.0.0 https://github.com/middlewares/https

Middleware to redirect to https and adds the Strict-Transport-Security header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 https http psr-15 strict-transport-security

13/11 2017

v0.6.0

0.6.0.0 https://github.com/middlewares/https

Middleware to redirect to https and adds the Strict-Transport-Security header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 https http psr-15 strict-transport-security

21/09 2017

v0.5.0

0.5.0.0 https://github.com/middlewares/https

Middleware to redirect to https and adds the Strict-Transport-Security header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 https http psr-15 strict-transport-security

28/01 2017

v0.4.0

0.4.0.0 https://github.com/middlewares/https

Middleware to redirect to https and adds the Strict-Transport-Security header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 https http psr-15 strict-transport-security

26/12 2016

v0.3.0

0.3.0.0 https://github.com/middlewares/https

Middleware to redirect to https and adds the Strict-Transport-Security header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 https http psr-15 strict-transport-security

27/11 2016

v0.2.0

0.2.0.0 https://github.com/middlewares/https

Middleware to redirect to https and adds the Strict-Transport-Security header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 https http psr-15 strict-transport-security

08/10 2016

v0.1.0

0.1.0.0 https://github.com/middlewares/https

Middleware to redirect to https and adds the Strict-Transport-Security header

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 https http psr-15 strict-transport-security