https://github.com/novactive/novaezprotectedcontentbundle
An eZ Platform bundle that provides quick protection on Contents
https://github.com/novactive/novaezprotectedcontentbundle
Last synced: 11 months ago
JSON representation
An eZ Platform bundle that provides quick protection on Contents
- Host: GitHub
- URL: https://github.com/novactive/novaezprotectedcontentbundle
- Owner: Novactive
- License: mit
- Created: 2018-04-24T12:37:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-20T14:20:16.000Z (over 1 year ago)
- Last Synced: 2024-12-31T19:34:03.794Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 153 KB
- Stars: 2
- Watchers: 17
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Novactive eZ Protected Content Bundle
----
This repository is what we call a "subtree split": a read-only copy of one directory of the main repository.
It is used by Composer to allow developers to depend on specific bundles.
If you want to report or contribute, you should instead open your issue on the main repository: https://github.com/Novactive/Nova-eZPlatform-Bundles
Documentation is available in this repository via `.md` files but also packaged here: https://novactive.github.io/Nova-eZPlatform-Bundles/master/ProtectedContentBundle/README.md.html
----
[](https://packagist.org/packages/novactive/ezprotectedcontentbundle)
[](https://github.com/Novactive/NovaeZProtectedContentBundle/releases)
[](LICENSE)
A bundle that provides quick password protection on Contents.
## How does it work?
Allows you to add 1 on N password on a Content in the Admin UI.
Once a Password is set, the Content becomes Protected. In this situation you will have 2 new variables in the view full.
Allowing you do:
```twig
{{ ibexa_content_name(content) }}
{% if not canReadProtectedContent %}
This content has been protected by a password
{{ form(requestProtectedContentPasswordForm) }}
{% else %}
{% for field in content.fieldsByLanguage(language|default(null)) %}
{{ field.fieldDefIdentifier }}
{{ ez_render_field(content, field.fieldDefIdentifier) }}
{% endfor %}
{% endif %}
```
You can also manage this globally through the pagelayout wrapping the content block.
Once you have unlocked the content, __canReadProtectedContent__ will be __true__
> HTTP Cache is disabled for Protected Content.
## Installation
### Installation steps
Add the lib to your composer.json, run `composer require novactive/ezprotectedcontentbundle` to refresh dependencies.
Then inject the bundle in the `bundles.php` of your application.
```php
Novactive\Bundle\eZProtectedContentBundle\NovaeZProtectedContentBundle::class => [ 'all'=> true ],
```
### Add routes
```yaml
_novaezprotectedcontent_routes:
resource: '@NovaeZProtectedContentBundle/Resources/config/routing/main.yml'
```
### Install the database schema
```bash
bin/console novaezprotectedcontent:install
```
### Varnish
This module add a cookie to unlock the contents that match it, for that reason you want to keep all the cookie that
starts with PasswordProvided::COOKIE_PREFIX (i.e: **protected-content-**).
```vcl
// Remove all cookies besides Session ID, as JS tracker cookies and so will make the responses effectively un-cached
if (req.http.cookie) {
set req.http.cookie = ";" + req.http.cookie;
set req.http.cookie = regsuball(req.http.cookie, "; +", ";");
set req.http.cookie = regsuball(req.http.cookie, ";[ ]*(eZSESSID[^=]*|protected-content-[^=]*)=", "; \1=");
set req.http.cookie = regsuball(req.http.cookie, ";[^ ][^;]*", "");
set req.http.cookie = regsuball(req.http.cookie, "^[; ]+|[; ]+$", "");
}
```