2017 © Pedro Peláez
 

package django-signer

Package for signing with timestamp (django like).

image

kyslik/django-signer

Package for signing with timestamp (django like).

  • Monday, April 24, 2017
  • by Kyslik
  • Repository
  • 1 Watchers
  • 1 Stars
  • 197 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

django-signer

Latest Version Build Status, (*1)

This package is upgraded version of cwygoda/signing package, with timestamps support to match django 1.10 functionality., (*2)

Setup

Composer

Pull this package in through Composer (development/latest version dev-master), (*3)

{
    "require": {
        "kyslik/django-signer": "0.0.*"
    }
}
$ composer update

for Laravel 5.4

add timestamp-signer service provider, (*4)

Kyslik\Django\Signing\SignerServiceProvider::class,

Usage

Instantiate new Signer object:, (*5)

$signer = new Kyslik\Django\Signing\Signer('secret-key');

Note: $separator defaults to :, $salt defaults to django.core.signing, (*6)

Note: Exception is thrown in case of unsuccesfull unsigning., (*7)

Signing / unsigning without timestamp

You may sign a string:

$signer->sign('string'); // string:UDxi2Kxw-SF3UBWhiflQNiAQWeU

Unsign string (check validity):

$signer->unsign('string:UDxi2Kxw-SF3UBWhiflQNiAQWeU'); // string

Signing / unsigning with timestamp

Note: you may use Signer::WITH_TIMESTAMP instead of true as second parameter, (*8)

Sign string:

$signer->sign('string', true); // string:1ckUX7:o-VQHm4f82K8106IXlc36S5Cumw

Unsign string (check validity):

$signer->unsign('string:1ckUX7:o-VQHm4f82K8106IXlc36S5Cumw', true) // string

Unsign string and check max_age (in seconds):

$signer->setMaxAge(10)->unsign('string:1ckUX7:o-VQHm4f82K8106IXlc36S5Cumw', true);

Signing / unsigning object

$array = ['user' => 'abc'];

$dumped = $signer->dumps($array); // eyJ1c2VyIjoiYWJjIn0:1ckV8v:OFnlhdYlNBCgixtl3XErbUh2Jug
$laoded = $signer->loads($dumped);

//verify
var_dump(($loaded === $array)) // true

The Versions

24/04 2017

dev-master

9999999-dev

Package for signing with timestamp (django like).

  Sources   Download

MIT

The Requires

 

The Development Requires

by Martin Kiesel

laravel timestamp django sign

24/04 2017

0.0.4

0.0.4.0

Package for signing with timestamp (django like).

  Sources   Download

MIT

The Requires

 

The Development Requires

by Martin Kiesel

laravel timestamp django sign

07/03 2017

0.0.3

0.0.3.0

Package for signing with timestamp (django like).

  Sources   Download

MIT

The Requires

 

The Development Requires

by Martin Kiesel

laravel timestamp django sign

06/03 2017

0.0.2

0.0.2.0

Package for signing with timestamp (django like).

  Sources   Download

MIT

The Requires

 

The Development Requires

by Martin Kiesel

laravel timestamp django sign

06/03 2017

0.0.1

0.0.1.0

Package for signing with timestamp (django like).

  Sources   Download

MIT

The Requires

 

The Development Requires

by Martin Kiesel

laravel timestamp django sign