Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/owowagency/deny-piet
Deny Pieter-Jan from your API
https://github.com/owowagency/deny-piet
Last synced: 11 days ago
JSON representation
Deny Pieter-Jan from your API
- Host: GitHub
- URL: https://github.com/owowagency/deny-piet
- Owner: owowagency
- License: mit
- Created: 2020-12-11T15:46:29.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-11T15:47:17.000Z (about 4 years ago)
- Last Synced: 2024-12-19T21:50:11.088Z (20 days ago)
- Language: PHP
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Anit Piet
Pieter-Jan is our boss, and he's from Belgium. Being Dutch, we of course don't like him*. That's why we created this package which can deny Piet his access to our API's.
# Installation
Installing this package can be done easily via the following Artisan command.
```bash
composer require owowagency/deny-piet
```# Setup
To install all the vendor files you can run the following command.
```bash
php artisan vendor:publish --provider="OwowAgency\DenyPiet\ServiceProvider"
```This will copy the configuration file.
## Config
Despite the fact that Pieter-Jan is from Belgium, he can me smart (sometimes). So to make this package effective we can block all email address of Piet. By default, we've blocked his main mail address which is "pieter (at) owow (dot) io". If you would like to block more of his email address you can add those to the `email` configuration value.
# Usage
## Validation rule
A validation rule will help you to block Piet from (i.e.) registering or logging in. You can use the validation rule as followed:
```php
$rules = [
'email' => [
'required',
'email',
new \OwowAgency\DenyPiet\Http\Rules\PietNotAllowed(),
],
];
```## Middleware
Of course, it could also happen that Piet bribed somebody in the office to manually enter his email address in the database. Therefore, we've created a middleware to check if the current authenticated user is Piet. If so, we'll deny his access.
This middleware is also handy for existing application where Piet already registered.
To implement the middleware you should add it to the `$middleware` array in `App\Http\Kernel.php`:
```php
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\OwowAgency\DenyPiet\Middleware\DenyAccessToPiet::class,
];
```---
* Just kidding Piet, we love you ❤️.