Message-ID: <2022898294.3144.1485852195829.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3143_1415875839.1485852195829" ------=_Part_3143_1415875839.1485852195829 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Authentication

Authentication

=20 =20

Authe= ntication using Symfony Security component

Native and = universal form_login is used, in co= njunction with an extended DaoAuthenticationProvider (DAO stands for Data Access Object= ), the RepositoryAuthenticationProvider. Nat= ive behavior of DaoAuthenticationProvider&nb= sp;has been preserved, making it possible to still use it for pure Symfony = applications.

Security controller

SecurityController is used to manage all securi= ty-related actions and is thus used to display login form. It is pretty str= aightforward and follows all standards explained in Symfony security documentation.

Base template used is EzPublishCoreBundle:Security:login.html= .twig and stands as follows:

=20
{% extends layout %}

{% block content %}
    {% block login_content %}
        {% if error %}
            <div>{{ error.message|trans }}</div>
        {% endif %}

        <form action=3D"{{ path( 'login_check' ) }}" method=3D"post">
        {% block login_fields %}
            <label for=3D"username">{{ 'Username:'|trans }}</label=
>
            <input type=3D"text" id=3D"username" name=3D"_username" valu=
e=3D"{{ last_username }}" />

            <label for=3D"password">{{ 'Password:'|trans }}</label=
>
            <input type=3D"password" id=3D"password" name=3D"_password" =
/>

            <input type=3D"hidden" name=3D"_csrf_token" value=3D"{{ csrf=
_token("authenticate") }}" />

            {#
                If you want to control the URL the user
                is redirected to on success (more details below)
                <input type=3D"hidden" name=3D"_target_path" value=3D"/a=
ccount" />
            #}

            <button type=3D"submit">{{ 'Login'|trans }}</button>=
;
        {% endblock %}
        </form>
    {% endblock %}
{% endblock %}
=20

The layout used by default is %ezpublish.c= ontent_view.viewbase_layout% (empty layout) but can be co= nfigured easily together with the login template:

ezplatform.yml
=20
ezpublish:
    system:
        my_siteaccess:
            user:
                layout: "AcmeTestBundle::layout.html.twig"
                login_template: "AcmeTestBundle:User:login.html.twig"
= =20

Redirection after login

By default, Symfony redirects to the URI configured in security.yml as = ;default_target_path. If not set, it will default to = /.

This setting can be set by siteaccess, via default_page se= tting.

Configuration

To use Symfony authentication with eZ Platform, the configuration = goes as follows:

app/config/security.yml
=20
security:
    firewalls:
        ezpublish_front:
            pattern: ^/
            anonymous: ~
            form_login:
                require_previous_session: false
            logout: ~
=20
app/config/routing.yml
=20
login:
    path:   /login
    defaults:  { _controller: ezpublish.security.controller:loginAction }
login_check:
    path:   /login_check
logout:
    path:   /logout
=20

Note

You can fully customize the routes and/or the controller used for login.= However, remember to match login_path, check_path and logout.path from security.yml.

See security configuration re= ference and stan= dard login form documentation.

 

Access control

See the do= cumentation on access control.

Remember me

It is possible to use the remember_me functionali= ty. For this you can refer to the Symfony cookbook on this topic.

If you want to use this feature, you must at least extend the login temp= late in order to add the required checkbox:

=20
{# your_login_template.html.twig #}
{% extends "EzPublishCoreBundle:Security:login.html.twig" %}

{% block login_fields %}
    {{ parent() }}
    <input type=3D"checkbox" id=3D"remember_me" name=3D"_remember_me" ch=
ecked />
    <label for=3D"remember_me">Keep me logged in</label>
{% endblock %}
=20

Login handlers / SSO

Symfony provides native support for multiple user providers. This makes it easy to i= ntegrate any kind of login handlers, including SSO and existing third-party= bundles (e.g. FR3DLdapBundleHWIOauthBundleFOSUserBundle= , BeSimpleSsoAuthBundle, etc.).

Further explanation can be found in the multiple user pro= viders cookbook entry.

Integration with Legacy
  • When not in legacy mode, legacy u= ser/login and user/logout views are deac= tivated.
  • Authenticated user is injected in legacy kernel.

Authenticatio= n with Legacy SSO Handlers

To be able to use your legacy SSO (Single Sign-on) handlers, use the fol= lowing config in your ezpublish/config/security.yml:

Use your legacy SSO handlers
=20
security:
    firewalls:
        ezpublish_front:
            pattern: ^/
            anonymous: ~
            # Adding the following entry will activate the use of old SSO h=
andlers.
            ezpublish_legacy_sso: ~ 
=20

 

 

------=_Part_3143_1415875839.1485852195829--