Download the PHP package mmdm/sim-csrf without Composer

On this page you can find all versions of the php package mmdm/sim-csrf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sim-csrf

Simplicity CSRF

A library for CSRF token management.

Install

composer

Or you can simply download zip file from github and extract it, then put file to your project library and use it like other libraries.

Just add line below to autoload files:

and you are good to go.

How to use

__construct(ICsrfStorage $storage = null)

You can pass custom storage if you want. Just implement ICsrfStorage class and pass it through constructor and you are good to go.

Go to Custom Csrf Storage section for more information about how to create custom storage.

Available functions

You can set storage even after construction with this method.

Get csrf storage.

This method set expiration from now to a csrf token. Default expiration is 300 seconds.

Note: If you plan to get token continuously if a code snipped then you should specify expiration each time before getting field or token.

exp. If you don't specify expiration in any of them, it has no problem and all of them will be default expiration, but if you specify in one of them, you should speficy expiration after that in each of usage

No problem example:

Problematic example:

Get expiration time.

By default it'll extend timeout of csrf if implemented in storage class or if you want to prevent this behavior you can send false to this method.

Important Note: If you set expiration to 7200 seconds(2 hours) and extend functionality is on, after each successful csrf validation, it'll extend the expiration. It means you have 3600 seconds left for example and a form has been submitted, now you have 7200 seconds again because you did not off extend functionality but if you turn this functionality off or you have a custom csrf stroge that did not implement any functionality in extend method, now if you have 3600 seconds expiration time and submit a form, you have 3600 seconds left and time not extended.

Added from v1.2.0

This method will return input with type hidden and value of token. The $name is an ID to generated token and $input_name is the name of hidden input.

This method will return token value only.

Note: If we had token with $name before and it is valid, returns it.

This method unlike getToken, returns a new token every time.

This method validate a token.

This method clears all generated token.

Custom Csrf Storage

Just implement ICsrfStorage interface

Important Note: All $key parameters has an extra prefix that is concatenated with a dot to token's hashed name.

License

Under MIT license.


All versions of sim-csrf with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
ext-openssl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mmdm/sim-csrf contains the following files

Loading the files please wait ....