Download the PHP package epubli4/permission-bundle without Composer

On this page you can find all versions of the php package epubli4/permission-bundle. 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 permission-bundle

API Platform Permissions

Package to ease the use of permissions for microservices in e4 which use api-platform.

Installation

Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

Recommended for unit tests:

Applications that don't use Symfony Flex

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

Recommended for unit tests:

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

Configuration

Make sure to insert the name of your microservice in config/packages/epubli_permission.yaml (create this file if it doesn't already exist) Example:

Create this file if it doesn't already exist config/packages/test/epubli_permission.yaml:

Activate the doctrine filter in config/packages/doctrine.yaml:

Usage

Generally

You need to specify the security key to enable this bundle for this endpoint.

If you want the bundle to differentiate between users who own an entity of this class or not, then you need to implement the SelfPermissionInterface.

Or use the SelfPermissionTrait for the default implementation of the SelfPermissionInterface:

If you have an entity without an userId but with a relationship to another entity with an userId, you need to implement the methods of SelfPermissionInterface yourself.

AccessToken

You can use this like a service. It supports autowiring. This gives you access to the properties of the access token of the user.

Custom permissions

For custom permissions to work you need to add an annotation to the method you are using it in.

Example:

The name of your microservice will be prepended automatically to the permission key.

Tests

To test your application with this bundle you need some way to send JsonWebTokens to it, otherwise testing the endpoints would be impossible, your requests would be denied.

You will need at least version v0.1.21 of https://github.com/epubli/api-platform-test

The easiest way is to just include the following into your test cases. That way every request will have the access rights to every endpoint.

If you want more control and don't want every request to have a token:

The trait UnitTestTrait exists to help you write unit tests for the common use cases. This trait has a config (self::$unitTestConfig) in which you describe your entity. This trait executes/generates unit tests for you. It requires you to implement methods which return the data used in the unit tests. Here is an example on how to use it for an entity which supports any operation:

If your entity does not support every operation, you need to adjust the config:

Export Command

To export the permissions of your microservice to the user microservice you need to execute the following in the docker container:

Testing

Execute the following:

or

How to change/add code to this bundle

The easiest way to further develop this bundle is to copy the src folder oder to another project (e.g. user microservice).

Create a folder named permission-bundle in the project and copy the src folder into it.

Then look for this in composer.json:

and replace it with:

Delete the original permission-bundle in the vendor folder.

Execute:

You may need to delete a few things in var/cache/dev.

Problems

When requesting multiple entities through a GET-Request hydra:totalItems can be incorrect when using the SelfPermissionInterface.

Because the paginator gets called before any filters are applied to the query the count of items/entities will be wrong. hydra:totalItems does not equal the number of items/entities returned.

The solution in this thread did not work: https://github.com/api-platform/core/issues/1185

Things which need to be done


All versions of permission-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
api-platform/api-pack Version ^1.2
ext-json Version *
doctrine/orm Version ^2.6
symfony/framework-bundle Version ^4.4
guzzlehttp/guzzle Version ^6.5
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 epubli4/permission-bundle contains the following files

Loading the files please wait ....