All Projects → Propaganistas → Laravel Fakeid

Propaganistas / Laravel Fakeid

Licence: mit
Automatic model ID obfuscation in routes for Laravel

Projects that are alternatives of or similar to Laravel Fakeid

Optimus
🤖 Id obfuscation based on Knuth's multiplicative hashing method for PHP.
Stars: ✭ 1,084 (+573.29%)
Mutual labels:  hashids, laravel, obfuscation
Eloquent Hashids
On-the-fly hashids for Laravel Eloquent models. (🍰 Easy & ⚡ Fast)
Stars: ✭ 196 (+21.74%)
Mutual labels:  hashids, laravel
Laravel Hashids
A Hashids bridge for Laravel
Stars: ✭ 1,714 (+964.6%)
Mutual labels:  hashids, laravel
id-mask
IDMask is a Java library for masking internal ids (e.g. from your DB) when they need to be published to hide their actual value and to prevent forging. It has support optional randomisation has a wide support for various Java types including long, UUID and BigInteger. This library bases its security on strong cryptographic primitives.
Stars: ✭ 39 (-75.78%)
Mutual labels:  hashids, obfuscation
Laravel Hashids
Integrate Hashids with Laravel. Automatic model binding and id resolving included!
Stars: ✭ 8 (-95.03%)
Mutual labels:  hashids, laravel
Laravel Hashid
Obfuscate your data by generating reversible, non-sequential, URL-safe identifiers.
Stars: ✭ 354 (+119.88%)
Mutual labels:  hashids, laravel
idy
👓 An ID obfuscator for ActiveRecord
Stars: ✭ 15 (-90.68%)
Mutual labels:  hashids, obfuscation
Laravel Optimus
Transform your internal id's to obfuscated integers based on Knuth's integer hash. Laravel wrapper for the Optimus Library by Jens Segers with multiple connections support.
Stars: ✭ 119 (-26.09%)
Mutual labels:  hashids, laravel
Laravel Hashslug
Package providing a trait to use Hashids on a model
Stars: ✭ 136 (-15.53%)
Mutual labels:  hashids, laravel
Captcha
Captcha for Laravel 5/6/7/8
Stars: ✭ 1,985 (+1132.92%)
Mutual labels:  laravel
Pingcrm React
⚛️ Ping CRM React - A demo app to illustrate how Inertia.js works with Laravel and React (hosted on a heroku free dyno).
Stars: ✭ 158 (-1.86%)
Mutual labels:  laravel
Online Ftp S3
Online FTP / Amazon S3 Filebrowser
Stars: ✭ 157 (-2.48%)
Mutual labels:  laravel
Tastyigniter
🔥 Powerful, yet easy to use, open-source online ordering, table reservation and management system for restaurants
Stars: ✭ 2,137 (+1227.33%)
Mutual labels:  laravel
Laravel Enum
Laravel support for spatie/enum
Stars: ✭ 158 (-1.86%)
Mutual labels:  laravel
Searchable
A php trait to search laravel models
Stars: ✭ 1,923 (+1094.41%)
Mutual labels:  laravel
Laravel 8 Stisla Jetstream
Laravel 8 + Jetstream + Livewire + Stisla
Stars: ✭ 159 (-1.24%)
Mutual labels:  laravel
Magutticms
Laravel 8 CMS for Web Artisans
Stars: ✭ 155 (-3.73%)
Mutual labels:  laravel
Restful Api With Laravel Definitive Guide
Repository with the base code for the course "RESTful API with Laravel - Definitive-Guide"
Stars: ✭ 156 (-3.11%)
Mutual labels:  laravel
Laravel Early Access
This package makes it easy to add early access mode to your existing application.
Stars: ✭ 160 (-0.62%)
Mutual labels:  laravel
Bdgt
Big finance tools in a small package
Stars: ✭ 159 (-1.24%)
Mutual labels:  laravel

Laravel FakeID

Tests Latest Stable Version Total Downloads License

Enables automatic Eloquent model ID obfuscation in routes using Optimus.

Installation

  1. Run the Composer require command to install the package

    composer require propaganistas/laravel-fakeid
    
  2. The package will automatically register itself.

  3. Run the following artisan command to auto-initialize the package's settings

    php artisan fakeid:setup
    

Usage

First of all, make sure the model is bound to Laravel's Router using the model() method, e.g. on top of the routes.php file (or in the boot() method of RouteServiceProvider if you use route caching):

Route::model('mymodel', 'App\MyModel');

This way you can reference a placeholder in your routes (edit/{mymodel}). By default Laravel will insert the model's primary key in the placeholder. But...

...if you then import the RoutesWithFakeIds trait into your model:

use Illuminate\Database\Eloquent\Model;
use Propaganistas\LaravelFakeId\RoutesWithFakeIds;

class MyModel extends Model {

  use RoutesWithFakeIds;

}

...all routes generated for this particular model will expose a fake ID instead of the raw primary key. Moreover incoming requests containing those fake IDs are automatically converted back to a real ID. The obfuscation layer is therefore transparent and doesn't require you to rethink everything. Just use Laravel as you normally would.

Example

Assuming an Article model having a named show route.

routes/web.php:

Route::model('article', 'App\Article');

Route::get('articles/{article}', '[email protected]')->name('articles.show');

app/Article.php

use Illuminate\Database\Eloquent\Model;
use Propaganistas\LaravelFakeId\RoutesWithFakeIds;

class Article extends Model {
  use RoutesWithFakeIds;
}

A route to this specific endpoint can now be generated using Laravel's route() helper, and it will automatically contain a fake ID:

<a href="{{ route('articles.show', $article) }}"> {{ $article->name }} </a>

FAQ

Why didn't you implement Hashids instead of Optimus?

PERFORMANCE! Optimus is based on Knuth's multiplicative hashing method and proves to be quite faster than Hashids. It's even mentioned on Hashids' own website.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].