Navigation
eZ Documentation Center
 

This is outdated documentation made for eZ Publish Platform 5.2. It is being moved into the eZ Publish 5.x documentation, so please go there for most up-to-date documentation.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Note
titleVersion compatibility

This recipe is compatible with eZ Publish 5.2 / 2013.07

Table of Contents

Info

Be sure to have read Context aware HTTP cache documentation before reading this recipe.

Description

When user hash generation is requested, eZ Publish will create a hashable User Identity object.

One can add information to the Identity object making the resulted hash vary. This can be done by registering Identity definers.

For this, all you need to do is to declare a service with ezpublish.identity_definer tag. Class for this service must implement eZ\Publish\SPI\User\IdentityAware interface.

Example

Code Block
titleservices.yml (inside a bundle)
parameters:
    my_identity_definer.class: Acme\TestBundle\Identity\MyDefiner
 
services:
    my_identity_definer:
        class: %my_identity_definer.class%
        tags:
            - { name: ezpublish.identity_definer }
Code Block
languagephp
<?php

namespace Acme\TestBundle\Identity;

use eZ\Publish\SPI\User\IdentityAware;
use eZ\Publish\SPI\User\Identity;

class MyDefiner implements IdentityAware
{
    public function setIdentity( Identity $identity )
    {
        // Here I can add information to $identity.
        // value MUST be scalar.
        $identity->setInformation( 'my_key', 'my_value' );
    }
}

Securing hash generation request

By default, hash generation requests are granted for localhost (127.0.0.1::1fe80::1).

If you want to enlarge the scope (e.g. if your Varnish server is not running on the same machine), you can override canGenerateUserHash() protected method in your main kernel class (mostly EzPublishKernel).