GithubHelp home page GithubHelp logo

debiano / eloquent-signature Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeckel/eloquent-signature

0.0 0.0 0.0 9 KB

Add signature check on your Eloquent models

License: MIT License

PHP 100.00%

eloquent-signature's Introduction

eloquent-signature

Add a signature integrity check in your Eloquent model

Installation

To get started, install secure-eloquent via Composer:

composer require jeckel/eloquent-signature

Next add the HasSignature trait and the Signable interface to your model

<?php
namespace App;

use Jeckel\EloquentSignature\HasSignature;
use Jeckel\EloquentSignature\Signable;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements Signable
{
    use HasSignature;
    
    /**
     * Required 
     */
    protected static $signatureProperties = ['login', 'email', 'password'];
    
    /**
     * Required   
     */
    protected static $signatureSalt = 'MySalt';
    
    /**
     * Optional (default: 'signature')  
     */
    protected $signatureFieldName = 'signature';
    
    /**
     * Optional (default: false) 
     */
    protected $throwExceptionOnRetrieve = false;
}

Field description :

  • signatureProperties: fields which will be include in the signature check, if any of this field is updated without updating the model will cause an integrity check error
  • signatureSalt: String to include in the signature calculation
  • signatureFieldName: name of the field in your model where the calculated signature will be stored
  • throwExceptionOnRetrieve: if set to true, all find queries will throw an exception if the signature retrieved is invalid. Using this options is more secure but need some implementation on your side to handle this exception.

Methods :

  • checkSignatureIsValid: allow you to check the signature when you need in your code.

eloquent-signature's People

Contributors

debiano avatar jeckel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.