<commit_before>Big Picture
===========

What is problem?
^^^^^^^^^^^^^^^^

In some kind of applications we need to restrict access to specific tables and/or rows and/or columns based on some context (e.g. User Permissions, Application Permissions and so on). 

And there is no build-in way or some kind of library to implement such kind of things in **application layer**.

How we solve this?
^^^^^^^^^^^^^^^^^^

We introduce EntityFramework.Guardian. This solution allows you to implement database security in easy and **right** way.
Guardian introduces set of interfaces for implementing entitites that are presenting permissions that are linked to entity type, row and columns. 

Guardian set two guards for Modifing and Retrieving operations:

* Retrieve ( *get* ) guard is set in ObjectContext.ObjectMaterialized event.
* Modify ( *add, update, delete* ) guard is set in ObjectContext.SavingChanges event.

General part of guardian is `GuardianKernel`. This object holds following components:

* :ref:`Guards <refGuards>` - ModifyGuard and RetrieveGuard, these guards invoke defined policies
* :ref:`Policies <refPolicies>` - Policies define set of rules to be applyed to entities and permissions
* :ref:`PermissionsService <refPermissionsService>` - Service for retrieving general and row level permissions.
* :ref:`EntityKeyProvider<refEntityKeyProvider>` - Service for returning string representation of passed entity identificator

All these components are configurable.<commit_msg>Update big_picture.rst<commit_after>Big Picture
===========

What is problem?
^^^^^^^^^^^^^^^^

In some kind of applications we need to restrict access to specific tables and/or rows and/or columns based on some context (e.g. User Permissions, Application Permissions and so on). 

And there is no build-in way or some kind of library to implement such kind of things in **application layer**.

How we solve this?
^^^^^^^^^^^^^^^^^^

We introduce EntityFramework.Guardian. This solution allows you to implement database security in easy and **right** way.

Guardian introduces access types:

.. code-block:: c#
    /// <summary>
    /// Access Types
    /// </summary>
    public enum AccessTypes
    {
        /// <summary>
        /// The get
        /// </summary>
        Get,
        /// <summary>
        /// The add
        /// </summary>
        Add,
        /// <summary>
        /// The update
        /// </summary>
        Update,
        /// <summary>
        /// The delete
        /// </summary>
        Delete
    }

Also Guardian introduces set of interfaces for implementing entitites that are presenting permissions that are linked to entity type, row and columns.

Here is simple entity interface that presents permission that is linked to entity type.

.. code-block:: c#
    /// <summary>
    /// Entity interfce presenting permission linked to entitytype
    /// </summary>
    public interface IPermission
    {
        /// <summary>
        /// Gets the name of the entity type.
        /// </summary>
        /// <value>
        /// The name of the entity type.
        /// </value>
        string EntityTypeName { get; }

        /// <summary>
        /// Gets the type of the access.
        /// </summary>
        /// <value>
        /// The type of the access.
        /// </value>
        AccessTypes AccessType { get; }
    }

Guardian set two guards for Modifing and Retrieving operations:

* Retrieve ( *get* ) guard is set in ObjectContext.ObjectMaterialized event.
* Modify ( *add, update, delete* ) guard is set in ObjectContext.SavingChanges event.

General part of guardian is `GuardianKernel`. This object holds following components:

* :ref:`Guards <refGuards>` - ModifyGuard and RetrieveGuard, these guards invoke defined policies
* :ref:`Policies <refPolicies>` - Policies define set of rules to be applyed to entities and permissions
* :ref:`PermissionsService <refPermissionsService>` - Service for retrieving general and row level permissions.
* :ref:`EntityKeyProvider<refEntityKeyProvider>` - Service for returning string representation of passed entity identificator

All these components are configurable.
{'fraction_non_alphanumeric': 0.10371442354076219, 'fraction_numerical': 0.0, 'mean_word_length': 3.101879327398615, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7360303', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1014, 'n_words': 464}