From 55b499e4c1e818df166a98d5fea05a5995bcefc4 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 27 Sep 2018 16:48:22 -0500 Subject: [PATCH 1/7] Bump minimum supported zend-expressive-authentication version to 1.0 Now that 1.0 is released and stable, we should no longer support pre-release versions. All tests continue to pass. --- composer.json | 2 +- composer.lock | 216 ++++++++++++++++++++------------------------------ 2 files changed, 86 insertions(+), 132 deletions(-) diff --git a/composer.json b/composer.json index 9f0ed9e..5e9b778 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "php": "^7.1", "psr/container": "^1.0", "psr/http-message": "^1.0.1", - "zendframework/zend-expressive-authentication": "^0.4.0 || ^1.0" + "zendframework/zend-expressive-authentication": "^1.0" }, "require-dev": { "phpunit/phpunit": "^7.0.1", diff --git a/composer.lock b/composer.lock index 68ff86b..d9afeb8 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ada3a2ee8fabbfb478fa123412e3c975", + "content-hash": "d15639d0e040b8e858a81e936a42756e", "packages": [ { "name": "psr/container", @@ -213,16 +213,16 @@ }, { "name": "zendframework/zend-expressive-authentication", - "version": "0.4.0", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/zendframework/zend-expressive-authentication.git", - "reference": "2fea5529d78cddc26921e46e87ea886ccb8cc7d1" + "reference": "52594067ffc149cd7defb87388e2c33707b5203f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-expressive-authentication/zipball/2fea5529d78cddc26921e46e87ea886ccb8cc7d1", - "reference": "2fea5529d78cddc26921e46e87ea886ccb8cc7d1", + "url": "https://api.github.com/repos/zendframework/zend-expressive-authentication/zipball/52594067ffc149cd7defb87388e2c33707b5203f", + "reference": "52594067ffc149cd7defb87388e2c33707b5203f", "shasum": "" }, "require": { @@ -274,7 +274,7 @@ "zend-expressive", "zf" ], - "time": "2018-03-15T17:19:40+00:00" + "time": "2018-08-27T15:09:06+00:00" } ], "packages-dev": [ @@ -334,25 +334,28 @@ }, { "name": "myclabs/deep-copy", - "version": "1.7.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", - "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" }, "require-dev": { "doctrine/collections": "^1.0", "doctrine/common": "^2.6", - "phpunit/phpunit": "^4.1" + "phpunit/phpunit": "^7.1" }, "type": "library", "autoload": { @@ -375,26 +378,26 @@ "object", "object graph" ], - "time": "2017-10-19T19:58:43+00:00" + "time": "2018-06-11T23:09:50+00:00" }, { "name": "phar-io/manifest", - "version": "1.0.1", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", - "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", "shasum": "" }, "require": { "ext-dom": "*", "ext-phar": "*", - "phar-io/version": "^1.0.1", + "phar-io/version": "^2.0", "php": "^5.6 || ^7.0" }, "type": "library", @@ -430,20 +433,20 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2017-03-05T18:14:27+00:00" + "time": "2018-07-08T19:23:20+00:00" }, { "name": "phar-io/version", - "version": "1.0.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", - "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", "shasum": "" }, "require": { @@ -477,7 +480,7 @@ } ], "description": "Library for handling version information and constraints", - "time": "2017-03-05T17:38:23+00:00" + "time": "2018-07-08T19:19:57+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -633,33 +636,33 @@ }, { "name": "phpspec/prophecy", - "version": "1.7.5", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401" + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401", - "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { @@ -692,31 +695,31 @@ "spy", "stub" ], - "time": "2018-02-19T10:16:54+00:00" + "time": "2018-08-05T17:53:17+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "6.0.1", + "version": "6.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f8ca4b604baf23dab89d87773c28cc07405189ba" + "reference": "865662550c384bc1db7e51d29aeda1c2c161d69a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f8ca4b604baf23dab89d87773c28cc07405189ba", - "reference": "f8ca4b604baf23dab89d87773c28cc07405189ba", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/865662550c384bc1db7e51d29aeda1c2c161d69a", + "reference": "865662550c384bc1db7e51d29aeda1c2c161d69a", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", "php": "^7.1", - "phpunit/php-file-iterator": "^1.4.2", + "phpunit/php-file-iterator": "^2.0", "phpunit/php-text-template": "^1.2.1", "phpunit/php-token-stream": "^3.0", "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.0", + "sebastian/environment": "^3.1", "sebastian/version": "^2.0.1", "theseer/tokenizer": "^1.1" }, @@ -755,29 +758,32 @@ "testing", "xunit" ], - "time": "2018-02-02T07:01:41+00:00" + "time": "2018-06-01T07:51:50+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.5", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + "reference": "050bedf145a257b1ff02746c31894800e5122946" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -792,7 +798,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -802,7 +808,7 @@ "filesystem", "iterator" ], - "time": "2017-11-27T13:52:08+00:00" + "time": "2018-09-13T20:33:42+00:00" }, { "name": "phpunit/php-text-template", @@ -945,35 +951,35 @@ }, { "name": "phpunit/phpunit", - "version": "7.0.2", + "version": "7.3.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e2f8aa21bc54b6ba218bdd4f9e0dac1e9bc3b4e9" + "reference": "7b331efabbb628c518c408fdfcaf571156775de2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e2f8aa21bc54b6ba218bdd4f9e0dac1e9bc3b4e9", - "reference": "e2f8aa21bc54b6ba218bdd4f9e0dac1e9bc3b4e9", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7b331efabbb628c518c408fdfcaf571156775de2", + "reference": "7b331efabbb628c518c408fdfcaf571156775de2", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "^1.6.1", - "phar-io/manifest": "^1.0.1", - "phar-io/version": "^1.0", + "myclabs/deep-copy": "^1.7", + "phar-io/manifest": "^1.0.2", + "phar-io/version": "^2.0", "php": "^7.1", "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^6.0", - "phpunit/php-file-iterator": "^1.4.3", + "phpunit/php-code-coverage": "^6.0.7", + "phpunit/php-file-iterator": "^2.0.1", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.0", - "phpunit/phpunit-mock-objects": "^6.0", - "sebastian/comparator": "^2.1", + "sebastian/comparator": "^3.0", "sebastian/diff": "^3.0", "sebastian/environment": "^3.1", "sebastian/exporter": "^3.1", @@ -982,10 +988,14 @@ "sebastian/resource-operations": "^1.0", "sebastian/version": "^2.0.1" }, + "conflict": { + "phpunit/phpunit-mock-objects": "*" + }, "require-dev": { "ext-pdo": "*" }, "suggest": { + "ext-soap": "*", "ext-xdebug": "*", "phpunit/php-invoker": "^2.0" }, @@ -995,7 +1005,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.0-dev" + "dev-master": "7.3-dev" } }, "autoload": { @@ -1021,63 +1031,7 @@ "testing", "xunit" ], - "time": "2018-02-26T07:03:12+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "6.0.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "e3249dedc2d99259ccae6affbc2684eac37c2e53" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/e3249dedc2d99259ccae6affbc2684eac37c2e53", - "reference": "e3249dedc2d99259ccae6affbc2684eac37c2e53", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.5", - "php": "^7.1", - "phpunit/php-text-template": "^1.2.1", - "sebastian/exporter": "^3.1" - }, - "require-dev": { - "phpunit/phpunit": "^7.0" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2018-02-15T05:27:38+00:00" + "time": "2018-09-08T15:14:29+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1126,30 +1080,30 @@ }, { "name": "sebastian/comparator", - "version": "2.1.3", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", - "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/diff": "^2.0 || ^3.0", + "php": "^7.1", + "sebastian/diff": "^3.0", "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^6.4" + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1186,20 +1140,20 @@ "compare", "equality" ], - "time": "2018-02-01T13:46:46+00:00" + "time": "2018-07-12T15:12:46+00:00" }, { "name": "sebastian/diff", - "version": "3.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "e09160918c66281713f1c324c1f4c4c3037ba1e8" + "reference": "366541b989927187c4ca70490a35615d3fef2dce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/e09160918c66281713f1c324c1f4c4c3037ba1e8", - "reference": "e09160918c66281713f1c324c1f4c4c3037ba1e8", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/366541b989927187c4ca70490a35615d3fef2dce", + "reference": "366541b989927187c4ca70490a35615d3fef2dce", "shasum": "" }, "require": { @@ -1242,7 +1196,7 @@ "unidiff", "unified diff" ], - "time": "2018-02-01T13:45:15+00:00" + "time": "2018-06-10T07:54:39+00:00" }, { "name": "sebastian/environment", From e3a2f8ddcfad6b36f5dc30ef32ac7d5aa30b7e28 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 27 Sep 2018 17:14:29 -0500 Subject: [PATCH 2/7] Prepare documentation for stable release - Version documentation - Provide full usage for package --- docs/book/intro.md | 12 ++--- docs/book/v1/intro.md | 108 ++++++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 7 +-- 3 files changed, 118 insertions(+), 9 deletions(-) create mode 100644 docs/book/v1/intro.md diff --git a/docs/book/intro.md b/docs/book/intro.md index 666c07c..c58aba4 100644 --- a/docs/book/intro.md +++ b/docs/book/intro.md @@ -1,6 +1,6 @@ -# zend-expressive-authentication-basic - -This component provides an HTTP Basic Authentication adapter for -[zend-expressive-authentication](https://docs.zendframework.com/zend-expressive-authentication). - -Docs are forthcoming... + + diff --git a/docs/book/v1/intro.md b/docs/book/v1/intro.md new file mode 100644 index 0000000..15ff765 --- /dev/null +++ b/docs/book/v1/intro.md @@ -0,0 +1,108 @@ +# zend-expressive-authentication-basic + +This component provides an HTTP Basic Authentication adapter for +[zend-expressive-authentication](https://docs.zendframework.com/zend-expressive-authentication). + +HTTP Basic authentication utilizes the user-info section of the URL authority in +order to provide credentials. While the HTTP specifications allow a single value +for the user-info, most implementations require a `:`-separated credential, with +the username first, and the password second; in fact, this is how browsers +always send HTTP Basic credentials, as their prompts are always for the two +values. As such, **this implementation expects both a username and password in +the supplied credentials**. + +> ### Only use in trusted networks +> +> Since HTTP Basic transmits the credentials via the URL, it should only be used +> within trusted networks, and never in public-facing sites, as the URL can be +> sniffed by MITM proxies. + +## Configuration + +To use the adapter, you will need to provide the following configuration: + +- A valid zend-expressive-authentication `UserRepositoryInterface` service in + your DI container. This service will perform the actual work of validating the + supplied credentials. + +- An HTTP Basic **realm**. This may be an arbitrary value, but is [required by + the specification](https://tools.ietf.org/html/rfc7617#section-2). + +- A response factory. If you are using Expressive, this is already configured + for you. + +As an example of configuration: + +```php +// config/autoload/authentication.global.php + +use Zend\Expressive\Authentication\AdapterInterface; +use Zend\Expressive\Authentication\Basic\BasicAccess; +use Zend\Expressive\Authentication\UserRepositoryInterface; +use Zend\Expressive\Authentication\UserRepository\PdoDatabase; + +return [ + 'dependencies' => [ + 'aliases' => [ + // Use the default PdoDatabase user repository. This assumes + // you have configured that service correctly. + UserRepositoryInterface::class => PdoDatabase::class, + + // Tell zend-expressive-authentication to use the BasicAccess + // adapter: + AdapterInterface::class => BasicAccess::class, + ], + ], + 'authentication' => [ + 'realm' => 'api', + ], +]; +``` + +## Usage + +Whenever you need an authenticated user, you can place the +zend-expressive-authentication `AuthenticationMiddleware` in your pipeline. + +### Globally + +If you need all routes to use authentication, add it globally. + +```php +// In config/pipeline.php, within the callback: + +$app->pipe(Zend\Expressive\Authentication\AuthenticationMiddleware::class); +``` + +### For an entire sub-path + +If you need all routes that begin with a particular sub-path to require +authentication, use [path-segregation](https://docs.zendframework.com/zend-stratigility/v3/api/#path): + +```php +// In config/pipeline.php. +// In the import statements: +use Zend\Expressive\Authentication\AuthenticationMiddleware; + +// In the callback: +$app->pipe('/api', $factory->path( + $factory->prepare(AuthenticationMiddleware::class) +)); +``` + +### For a specific route + +If you want to restrict access for a specific route, create a [route-specific +middleware pipeline](https://docs.zendframework.com/zend-expressive/v3/cookbook/route-specific-pipeline/): + +```php +// In config/routes.php, in the callback: + +$app->get( + '/path/requiring/authentication', + [ + Zend\Expressive\Authentication\AuthenticationMiddleware::class, + HandlerRequiringAuthentication::class, + ] +); +``` diff --git a/mkdocs.yml b/mkdocs.yml index bf3a0e6..a4ef625 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,9 +1,10 @@ docs_dir: docs/book site_dir: docs/html pages: - - index.md - - Introduction: intro.md + - Home: index.md + - Introduction: v1/intro.md + - "_hidden-legacy-page-links": + - "_intro": intro.md site_name: zend-expressive-authentication-basic site_description: 'HTTP Basic Authentication adapter for zend-expressive-authentication.' repo_url: 'https://github.com/zendframework/zend-expressive-authentication-basic' -copyright: 'Copyright (c) 2017 Zend Technologies USA Inc.' From 144405adfdf2e3899a8abbe34e8d298b037500d2 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 28 Sep 2018 08:46:47 -0500 Subject: [PATCH 3/7] Incorporate feedback - Per @froschdesign --- docs/book/v1/intro.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/book/v1/intro.md b/docs/book/v1/intro.md index 15ff765..5e69a9d 100644 --- a/docs/book/v1/intro.md +++ b/docs/book/v1/intro.md @@ -1,4 +1,4 @@ -# zend-expressive-authentication-basic +# Introduction This component provides an HTTP Basic Authentication adapter for [zend-expressive-authentication](https://docs.zendframework.com/zend-expressive-authentication). @@ -102,7 +102,7 @@ $app->get( '/path/requiring/authentication', [ Zend\Expressive\Authentication\AuthenticationMiddleware::class, - HandlerRequiringAuthentication::class, + HandlerRequiringAuthentication::class, // use your own handler here ] ); ``` From 01e86808c76828a2b6c5d9ff0548f0dbfe26b3a8 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 28 Sep 2018 08:48:36 -0500 Subject: [PATCH 4/7] Split docs into three pages - Intro for package introduction - Configuration - Usage --- docs/book/v1/config.md | 41 +++++++++++++++++++ docs/book/v1/intro.md | 90 ------------------------------------------ docs/book/v1/usage.md | 47 ++++++++++++++++++++++ mkdocs.yml | 2 + 4 files changed, 90 insertions(+), 90 deletions(-) create mode 100644 docs/book/v1/config.md create mode 100644 docs/book/v1/usage.md diff --git a/docs/book/v1/config.md b/docs/book/v1/config.md new file mode 100644 index 0000000..077000c --- /dev/null +++ b/docs/book/v1/config.md @@ -0,0 +1,41 @@ +# Configuration + +To use the adapter, you will need to provide the following configuration: + +- A valid zend-expressive-authentication `UserRepositoryInterface` service in + your DI container. This service will perform the actual work of validating the + supplied credentials. + +- An HTTP Basic **realm**. This may be an arbitrary value, but is [required by + the specification](https://tools.ietf.org/html/rfc7617#section-2). + +- A response factory. If you are using Expressive, this is already configured + for you. + +As an example of configuration: + +```php +// config/autoload/authentication.global.php + +use Zend\Expressive\Authentication\AdapterInterface; +use Zend\Expressive\Authentication\Basic\BasicAccess; +use Zend\Expressive\Authentication\UserRepositoryInterface; +use Zend\Expressive\Authentication\UserRepository\PdoDatabase; + +return [ + 'dependencies' => [ + 'aliases' => [ + // Use the default PdoDatabase user repository. This assumes + // you have configured that service correctly. + UserRepositoryInterface::class => PdoDatabase::class, + + // Tell zend-expressive-authentication to use the BasicAccess + // adapter: + AdapterInterface::class => BasicAccess::class, + ], + ], + 'authentication' => [ + 'realm' => 'api', + ], +]; +``` diff --git a/docs/book/v1/intro.md b/docs/book/v1/intro.md index 5e69a9d..ca97c40 100644 --- a/docs/book/v1/intro.md +++ b/docs/book/v1/intro.md @@ -16,93 +16,3 @@ the supplied credentials**. > Since HTTP Basic transmits the credentials via the URL, it should only be used > within trusted networks, and never in public-facing sites, as the URL can be > sniffed by MITM proxies. - -## Configuration - -To use the adapter, you will need to provide the following configuration: - -- A valid zend-expressive-authentication `UserRepositoryInterface` service in - your DI container. This service will perform the actual work of validating the - supplied credentials. - -- An HTTP Basic **realm**. This may be an arbitrary value, but is [required by - the specification](https://tools.ietf.org/html/rfc7617#section-2). - -- A response factory. If you are using Expressive, this is already configured - for you. - -As an example of configuration: - -```php -// config/autoload/authentication.global.php - -use Zend\Expressive\Authentication\AdapterInterface; -use Zend\Expressive\Authentication\Basic\BasicAccess; -use Zend\Expressive\Authentication\UserRepositoryInterface; -use Zend\Expressive\Authentication\UserRepository\PdoDatabase; - -return [ - 'dependencies' => [ - 'aliases' => [ - // Use the default PdoDatabase user repository. This assumes - // you have configured that service correctly. - UserRepositoryInterface::class => PdoDatabase::class, - - // Tell zend-expressive-authentication to use the BasicAccess - // adapter: - AdapterInterface::class => BasicAccess::class, - ], - ], - 'authentication' => [ - 'realm' => 'api', - ], -]; -``` - -## Usage - -Whenever you need an authenticated user, you can place the -zend-expressive-authentication `AuthenticationMiddleware` in your pipeline. - -### Globally - -If you need all routes to use authentication, add it globally. - -```php -// In config/pipeline.php, within the callback: - -$app->pipe(Zend\Expressive\Authentication\AuthenticationMiddleware::class); -``` - -### For an entire sub-path - -If you need all routes that begin with a particular sub-path to require -authentication, use [path-segregation](https://docs.zendframework.com/zend-stratigility/v3/api/#path): - -```php -// In config/pipeline.php. -// In the import statements: -use Zend\Expressive\Authentication\AuthenticationMiddleware; - -// In the callback: -$app->pipe('/api', $factory->path( - $factory->prepare(AuthenticationMiddleware::class) -)); -``` - -### For a specific route - -If you want to restrict access for a specific route, create a [route-specific -middleware pipeline](https://docs.zendframework.com/zend-expressive/v3/cookbook/route-specific-pipeline/): - -```php -// In config/routes.php, in the callback: - -$app->get( - '/path/requiring/authentication', - [ - Zend\Expressive\Authentication\AuthenticationMiddleware::class, - HandlerRequiringAuthentication::class, // use your own handler here - ] -); -``` diff --git a/docs/book/v1/usage.md b/docs/book/v1/usage.md new file mode 100644 index 0000000..f078c69 --- /dev/null +++ b/docs/book/v1/usage.md @@ -0,0 +1,47 @@ +# Usage + +Whenever you need an authenticated user, you can place the +zend-expressive-authentication `AuthenticationMiddleware` in your pipeline. + +## Globally + +If you need all routes to use authentication, add it globally. + +```php +// In config/pipeline.php, within the callback: + +$app->pipe(Zend\Expressive\Authentication\AuthenticationMiddleware::class); +``` + +## For an entire sub-path + +If you need all routes that begin with a particular sub-path to require +authentication, use [path-segregation](https://docs.zendframework.com/zend-stratigility/v3/api/#path): + +```php +// In config/pipeline.php. +// In the import statements: +use Zend\Expressive\Authentication\AuthenticationMiddleware; + +// In the callback: +$app->pipe('/api', $factory->path( + $factory->prepare(AuthenticationMiddleware::class) +)); +``` + +## For a specific route + +If you want to restrict access for a specific route, create a [route-specific +middleware pipeline](https://docs.zendframework.com/zend-expressive/v3/cookbook/route-specific-pipeline/): + +```php +// In config/routes.php, in the callback: + +$app->get( + '/path/requiring/authentication', + [ + Zend\Expressive\Authentication\AuthenticationMiddleware::class, + HandlerRequiringAuthentication::class, // use your own handler here + ] +); +``` diff --git a/mkdocs.yml b/mkdocs.yml index a4ef625..dc4fd8d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -3,6 +3,8 @@ site_dir: docs/html pages: - Home: index.md - Introduction: v1/intro.md + - Configuration: v1/config.md + - Usage: v1/usage.md - "_hidden-legacy-page-links": - "_intro": intro.md site_name: zend-expressive-authentication-basic From 267ef18bf0de97b2e50e1e1887306da250a74d20 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 28 Sep 2018 08:49:36 -0500 Subject: [PATCH 5/7] Adds php-nightly to test matrix - Future 7.3 --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 49bc879..f16a299 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,9 @@ matrix: - php: 7.2 env: - DEPS=latest + - php: nightly + env: + - DEPS=latest before_install: - if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi From 1f71859b3f6c051e53b5daa2b4dc60d70eca2ad9 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 28 Sep 2018 08:53:31 -0500 Subject: [PATCH 6/7] Updates branch aliases - Adds dev-develop => 1.1.x-dev --- composer.json | 3 ++- composer.lock | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5e9b778..e249525 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,8 @@ }, "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.0.x-dev", + "dev-develop": "1.1.x-dev" }, "zf": { "config-provider": "Zend\\Expressive\\Authentication\\Basic\\ConfigProvider" diff --git a/composer.lock b/composer.lock index d9afeb8..414434f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d15639d0e040b8e858a81e936a42756e", + "content-hash": "e9c006b06a72f002fbd3c4ac05414734", "packages": [ { "name": "psr/container", From 65f5f95f169d53b92a07ce1f147315e6ff2dd3d5 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Fri, 28 Sep 2018 08:53:53 -0500 Subject: [PATCH 7/7] Prepares CHANGELOG for 1.0.0 - Adds 1.0.0 section - Adds entries for #10 --- CHANGELOG.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 610d2bd..e868afe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,31 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## 1.0.0 - TBD + +### Added + +- [#10](https://github.com/zendframework/zend-expressive-authentication-basic/pull/10) adds support for the upcoming PHP 7.3 release. + +- [#10](https://github.com/zendframework/zend-expressive-authentication-basic/pull/10) adds full configuration and usage documentation. + +### Changed + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- [#10](https://github.com/zendframework/zend-expressive-authentication-basic/pull/10) removes support for pre-1.0 versions of + zendframework/zend-expressive-authentication. + +### Fixed + +- Nothing. + ## 0.3.1 - 2018-07-25 ### Added