tetracode / ncoder
laravel api encryption middleware by Tetracode
v1.0.2
2020-06-01 10:06 UTC
Requires
- ext-json: *
Requires (Dev)
- orchestra/testbench: ^5.1
This package is auto-updated.
Last update: 2025-03-01 00:24:20 UTC
README
Ncoder is a simple API call encryption middleware package designed to work on laravel Framework.
Installing Ncoder
install trough Composer.
composer require tetracode/ncoder
Configuration
Above Laravel 5.5 or higher no need to add service provider
if you are using laravel 5.4 or below add service provider to Config/app.php providers array
'providers' => [ Tetracode\Ncoder\NcoderBaseServiceProvider::class, ],
Add Ncoder middleware to routeMiddleware array in App/Http/Kernel.php
protected $routeMiddleware = [ 'ncoder'=>\Tetracode\Ncoder\Http\Middleware\EncryptHttp::class, 'xncoder'=>\Tetracode\Ncoder\Http\Middleware\ForceEncryptHttp::class, ]
php artisan vendor:publish --tag ncoder-config
php artisan ncoder:secret
Middleware Types
ncoder : this will encrypt response only requested in front end. xncoder : this will encrypt response no matter requested in front end or not.
Usage
Route
Route::middleware('ncoder')->post('api-endpoint', 'ApiController@store'); //Force Encrypt Response Route::middleware('xncoder')->post('api-endpoint', 'ApiController@store'); Route::group(['middleware' => ['ncoder']], function () { Route::post('api-endpoint', 'ApiController@store'); }); //Force Encrypt Response Route::group(['middleware' => ['xncoder']], function () { Route::post('api-endpoint', 'ApiController@store'); });
Controller
class UserController extends Controller { public function __construct() { $this->middleware(['ncoder']); } public function index() { return response()->json(User::all()); } }
OR
class UserController extends Controller { public function __construct() { $this->middleware(['xncoder']); } public function index() { return response()->json(User::all()); } }
Credits
Vue Package
License
The MIT License (MIT). Please see License File for more information.