Download the PHP package codemonster-ru/security without Composer

On this page you can find all versions of the php package codemonster-ru/security. 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 security

codemonster-ru/security

Latest Version on Packagist Total Downloads License Tests

codemonster-ru/security is a set of reusable security components for the Annabel ecosystem:

No Laravel/Symfony dependencies. Compatible with codemonster-ru/http and codemonster-ru/session.

Installation

For monorepo development, you can use a path repository (as in annabel-skeleton/composer.local.json).

Quick Start (Annabel)

Annabel loads providers from bootstrap/providers/*.php.

  1. Add a provider:

bootstrap/providers/SecurityServiceProvider.php

  1. Add config:

config/security.php

By default, CSRF is enabled globally (via Kernel::addMiddleware), but throttling is not (so as not to surprise all routes).

CSRF

How is it checked?

Codemonster\Security\Csrf\VerifyCsrfToken:

Security note: if your API uses cookies or other stateful auth, enable verify_json to protect JSON POST/PUT/PATCH/DELETE requests too.

Helpers

The package autoloads helpers:

Example in the form:

Throttle / Rate limiting

Codemonster\Security\RateLimiting\ThrottleRequests:

Best practices

Trusted proxies

If your app sits behind a reverse proxy or load balancer, configure trusted_proxies so the middleware can safely use X-Forwarded-For or X-Real-IP. When trusted_proxies is empty, only REMOTE_ADDR is trusted. Do not trust these headers unless the proxy is under your control.

Database storage (MySQL)

If you want atomic throttling across multiple nodes, use the database storage:

Register the package migrations path (Annabel):

Without Annabel/Database:

  1. Copy migrations from vendor/codemonster-ru/security/migrations into your project migrations directory.
  2. Run your migrations as usual.

Custom table name example:

Note: the bundled migration reads security.throttle.table to decide which table to create.

If you don't use migrations, create the table manually (adjust name if needed):

Redis storage

Provide a Redis client and set storage to redis:

Connection to the route

Router/Kernel in Annabel supports route-level middleware:

Preset example:

Restriction key

By default, the key is built from ip|method|path and hashed (sha1).

You can pass a callable instead of a role string:

Tests

Optional E2E env (tests are skipped if not set):

Author

Kirill Kolesnikov

License

MIT


All versions of security with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
codemonster-ru/http Version ^2.0
codemonster-ru/session Version ^2.0
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 codemonster-ru/security contains the following files

Loading the files please wait ...