https://github.com/settermjd/zend-expressive-authentication
This package provides HTML-based authentication middleware for Zend Expressive applications
https://github.com/settermjd/zend-expressive-authentication
Last synced: 8 months ago
JSON representation
This package provides HTML-based authentication middleware for Zend Expressive applications
- Host: GitHub
- URL: https://github.com/settermjd/zend-expressive-authentication
- Owner: settermjd
- License: mit
- Created: 2016-10-12T07:23:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-30T09:01:07.000Z (over 9 years ago)
- Last Synced: 2025-03-23T22:14:04.742Z (about 1 year ago)
- Language: PHP
- Size: 86.9 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Zend Expressive Authentication
This project provides PSR-7-compliant authentication middleware.
## Why?
This repository serves two purposes. Firstly, it serves as a supporting code repository for my talk [Build Powerful and Flexible Micro-Applications, with Zend Expressive](https://goo.gl/5Bysd2). And secondly, it provides a simplified set of PSR-7-compliant authentication middleware for a Zend Expressive (or other PSR-7) application.
If you’re in one of the sessions where I give this talk, then feel free to use this repository to both follow along or go further than I do in the talk, building and expanding on the content taught. If you need an drop-in authentication library, then feel free to use it, ignoring the tutorial/talk aspect.
## Installation
To install the code, depending on your needs, you can either clone the repository and browse through it, following along with the talk, by running:
```
git clone git@github.com:settermjd/zend-expressive-authentication.git
```
Alternatively, to integrate it with a PSR-7 compliant application, make use of Composer via the following command:
```
composer require settermjd/zend-expressive-authentication
```
As well as making the library available to your application as a core dependency, it will also copy the configuration files in place, assuming that you’re using it with Zend Expressive, and that your project directory structure follows the convention espoused by [the Zend Expressive Skeleton Installer](http://www.masterzendframework.com/zend-expressive-introduction/).
Currently, Zend Expressive is the only supported framework. Instructions for other PSR-7-compliant frameworks to follow.
## Usage
To make use of the project, there’s not much that you need to do. All that you need to do is to stack the `AuthenticationMiddleware` as part of the middleware stack for one, several, or all routes within your application. Here are two examples.
### Protecting a Single Route In An Application
```php
[
'name' => 'home',
'path' => '/',
'middleware' =>
[
\App\Middleware\AuthenticationMiddleware::class,
App\Action\HomePageAction::class,
],
'allowed_methods' => ['GET'],
],
```
### Protecting All Routes In An Application
```php
'routing' => [
'middleware' => [
ApplicationFactory::ROUTING_MIDDLEWARE,
\App\Middleware\AuthenticationMiddleware::class,
ApplicationFactory::DISPATCH_MIDDLEWARE,
],
'priority' => 1,
],
```
## Contributing
See the [CONTRIBUTING](CONTRIBUTING.md) file.