PHPackages                             ics/ssi-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. ics/ssi-bundle

ActiveSymfony-bundle[Security](/categories/security)

ics/ssi-bundle
==============

Bundle security extention

0.2.7(4y ago)31972MITPHP

Since Mar 28Pushed 4y ago2 watchersCompare

[ Source](https://github.com/imperiumclansoftware/ssi-bundle)[ Packagist](https://packagist.org/packages/ics/ssi-bundle)[ RSS](/packages/ics-ssi-bundle/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (20)Versions (27)Used By (2)

Imperium Clan Software - Ssi Bundle
===================================

[](#imperium-clan-software---ssi-bundle)

Symfony bundle for extend security and logging

Installation
------------

[](#installation)

Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Applications that use Symfony Flex

[](#applications-that-use-symfony-flex)

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

```
composer require ics/ssi-bundle
```

### Applications that don't use Symfony Flex

[](#applications-that-dont-use-symfony-flex)

#### Step 1: Download the Bundle

[](#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:

```
$ composer require ics/ssi-bundle
```

#### Step 2: Enable the Bundle

[](#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:

```
// config/bundles.php

return [
    // ...
    ICS\SsiBundle\SsiBundle::class => ['all' => true],
];
```

#### Step 3: Adding bundle routing

[](#step-3-adding-bundle-routing)

Add routes in applications `config/routes.yaml`

```
# config/routes.yaml

# ...
ssi_bundle:
    resource: '@SsiBundle/config/routes.yaml'
    prefix: /ssi
# ...
```

#### Step 4: Install Database

[](#step-4-install-database)

For install database :

```
# Installer la base de données

php bin/console doctrine:schema:create
```

For update database :

```
# Mise a jour la base de données

php bin/console doctrine:schema:update -f
```

### Adding bundle to [EasyAdmin](https://symfony.com/doc/current/bundles/EasyAdminBundle/index.html)

[](#adding-bundle-to-easyadmin)

#### Step 1: Add entities to dashboard

[](#step-1-add-entities-to-dashboard)

Add this MenuItems in your dashboard `Controller/Admin/DashboardController.php`

```
    // Controller/Admin/DashboardController.php
    use ICS\SsiBundle\Entity\Account;
    use ICS\SsiBundle\Entity\Log;

    class DashboardController extends AbstractDashboardController
    {
        public function configureMenuItems(): iterable
        {
            // ...
            yield MenuItem::section('Security', 'fa fa-shield');
            yield MenuItem::linkToCrud('Accounts', 'fa fa-user-circle', Account::class);
            yield MenuItem::linkToCrud('Logs', 'fa fa-newspaper', Log::class);
            // ...
        }
    }
```

#### Step 2: Add twig widgets to dashboard

[](#step-2-add-twig-widgets-to-dashboard)

```
    {# templates/admin/dashboard.html.twig #}

    {% extends "@EasyAdmin/page/content.html.twig" %}

    {% block page_content %}

        {% include "@Ssi/admin/logs.html.twig" %}

    {% endblock %}
```

Install bundle fixtures
-----------------------

[](#install-bundle-fixtures)

```
# Every data in database will destruct

php bin/console doctrine:fixture:load
```

The Passwords for created users are :

- admin : `adminPassword`
- user\[1~10\] : `userPassword`

Log Entity
----------

[](#log-entity)

For log an entity just add `@Log` Annotation on entity declaration you must define the `actions` and `property` properties

value for `actions` can :

- "add" *On add entity in database*
- "update" *On update entity in database*
- "delete" *On delete entity in database*
- "all" *On all action of entity in database*

for `property` make a property than return the log message you want

```
    use Doctrine\ORM\Mapping as ORM;
    use ICS\SsiBundle\Annotation\Log;
    /**
     * @ORM\Entity()
     * @ORM\Table()
     * @Log(actions={"all"},property="logMessage")
     */
    class Account implements UserInterface
    {
        /**
         * @ORM\Column(type="string", length=180, unique=true)
         */
        private $username;

        public function getLogMessage()
        {
            return $this->username.' (#'.$this->getId().')';
        }

    }
```

Configure keycloak authentification
-----------------------------------

[](#configure-keycloak-authentification)

For enabled a keycloak authentification add this lines in `.env` file :

```
    #Keycloak configuration

    KEYCLOAK_URL=""
    KEYCLOAK_REALM=""
    KEYCLOAK_CLIENT_ID=""
    KEYCLOAK_CLIENT_SECRET="
