Skip to content

Commit

Permalink
[skip ci][doc] fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
jcheron committed Jan 3, 2021
1 parent 39c9b06 commit 7dfb2d2
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 39 deletions.
58 changes: 31 additions & 27 deletions docs/controller/router.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,43 +99,47 @@ Static routes are defined using annotation or with php native attributes since `

Creation
^^^^^^^
With annotations:

.. code-block:: php
:linenos:
:caption: app/controllers/ProductsController.php
:emphasize-lines: 7-9
namespace controllers;
/**
* Controller ProductsController
*/
class ProductsController extends ControllerBase{
.. tabs::

/**
* @route("products")
*/
public function index(){}
.. tab:: Attributes

}
.. code-block:: php
:linenos:
:caption: app/controllers/ProductsController.php
:emphasize-lines: 7
With attributes:
namespace controllers;
.. code-block:: php
:linenos:
:caption: app/controllers/ProductsController.php
:emphasize-lines: 7
use Ubiquity\attributes\items\router\Route;
namespace controllers;
class ProductsController extends ControllerBase{
use Ubiquity\attributes\items\router\Route;
#[Route('products')]
public function index(){}
class ProductsController extends ControllerBase{
}
#[Route('products')]
public function index(){}
.. tab:: Annotations

.. code-block:: php
:linenos:
:caption: app/controllers/ProductsController.php
:emphasize-lines: 7-9
namespace controllers;
/**
* Controller ProductsController
*/
class ProductsController extends ControllerBase{
/**
* @route("products")
*/
public function index(){}
}
}
The method ``Products::index()`` will be accessible via the url ``/products``.

Expand Down
14 changes: 13 additions & 1 deletion docs/security/acl.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
.. _aclModule:
ACL management
**************

.. |br| raw:: html

<br />
<br />

Installation
============

Install the **Ubiquity-acl** module from the command prompt or from the **Webtools** (Composer part).

.. code-block:: bash
composer require phpmv/ubiquity-acl
Then activate the display of the Security part in the **Webtools**:
21 changes: 15 additions & 6 deletions docs/security/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Client-side validation
It is preferable to perform an initial client-side validation to avoid submitting invalid data to the server.

Example of the creation of a form in the action of a controller (this part could be located in a dedicated service for a better separation of layers):

.. code-block:: php
:linenos:
:caption: app/controllers/UsersManagement.php
Expand All @@ -36,6 +37,7 @@ Example of the creation of a form in the action of a controller (this part could
}
The Associated View:

.. code-block:: html+twig
:caption: app/views/UsersManagement/index.html
{{ q['frm-user'] | raw }}
Expand All @@ -45,7 +47,7 @@ The Associated View:
.. image:: /_static/images/security/bases/frm-user.png
:class: bordered

.. tip:: The CRUD controllers automatically integrate this client-side validation using the Validators attached to the members of the models.
.. note:: The CRUD controllers automatically integrate this client-side validation using the Validators attached to the members of the models.

.. code-block:: php
Expand All @@ -69,18 +71,19 @@ Beforehand, by specifying the Http method in the routes, and by testing the requ
}
}
.. tips:: The **Ubiquity-security** module offers additional control to avoid cross-site requests.
.. note:: The **Ubiquity-security** module offers additional control to avoid cross-site requests.

After modifying an object, it is possible to check its validity, given the validators attached to the members of the associated Model:

.. code-block:: php
#[Post(path: "/submit")]
public function submitUser(){
if(!URequest::isCrossSite() && URequest::isAjax()){
if(!URequest::isCrossSite()){
$datas=URequest::getPost();//post with htmlEntities
$user=new User();
URequest::setValuesToObject($user,$datas);
$violations=ValidatorsManager::validate($user);
if(\count($violations)==0){
//do something with this valid user
Expand All @@ -93,7 +96,7 @@ After modifying an object, it is possible to check its validity, given the valid
DAO operations
--------------
It is always recommended to use parameterized queries, regardless of the operations performed on the data.
It is always recommended to use parameterized queries, regardless of the operations performed on the data:
- To avoid SQL injections.
- To allow the use of prepared queries, speeding up processing.

Expand All @@ -105,7 +108,7 @@ It is always recommended to use parameterized queries, regardless of the operati
$countActiveUsers=DAO::count(User::class,'active= ?',[true]);
.. tips:: DAO operations that take objects as parameters use this mechanism by default.
.. note:: DAO operations that take objects as parameters use this mechanism by default.

.. code-block:: php
Expand Down Expand Up @@ -142,4 +145,10 @@ It is also possible to check a password entered by a user in the same way, to co
}
.. important:: Set up Https to avoid sending passwords in clear text.
.. important:: Set up Https to avoid sending passwords in clear text.

Security module/ ACL management
===============================
In addition to these few rules, you can install if necessary:
- :ref:`Ubiquity-acl<aclModule>`
- :ref:`Ubiquity-security<securityModule>`
11 changes: 6 additions & 5 deletions docs/security/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Then activate the display of the Security part in the **Webtools**:

.. image:: /_static/images/security/display-security.png
:class: bordered

Session CSRF
============

Expand All @@ -31,23 +32,23 @@ Encryption manager
==================
The **EncryptionManager** service can be started directly from the **webtools** interface.

- In this case, a key is generated in the configuration file `app/config/config.php`.
- In this case, a key is generated in the configuration file ``app/config/config.php``.

- The service is started in the `services.php` file.
- The service is started in the ``services.php`` file.

.. code-block:: php
:caption: app/config/services.php
\Ubiquity\security\data\EncryptionManager::start($config);
.. tips:: By default, encryption is performed in ``AES-256``.
.. note:: By default, encryption is performed in ``AES-256``.

.. image:: /_static/images/security/encryption-manager-started.png
:class: bordered

Cookie encryption
-----------------
Cookies can be encrypted by default, by adding this in `services.php`:
Cookies can be encrypted by default, by adding this in ``services.php``:

.. code-block:: php
:caption: app/config/services.php
Expand Down Expand Up @@ -86,6 +87,6 @@ To then decrypt it, with possible serialisation/deserialisation if it is an obje

.. code-block:: php
$user=EncryptionManager::encrypt($encryptedUser);
$user=EncryptionManager::decrypt($encryptedUser);

0 comments on commit 7dfb2d2

Please sign in to comment.