Skip to content

[Security] form login use_referer option not work. #17529

Closed
@yceruto

Description

@yceruto

I want redirect to the previous page when "login" is successful.

Given the following security settings:

# app/config/security.yml
security:
    # ...

    firewalls:
        main:
            # ...
            form_login:
                # ...
                # The documentation say:
                # In case no previous URL was stored in the session, 
                # you may wish to try using the HTTP_REFERER instead...
                use_referer: true

    access_control:
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/, role: ROLE_ADMIN }

Steps to reproduce the current behavior:
(1) Open /dashboard page (any page without authentication required)
(2) Open /login page (HTTP_REFERER = 'http://example.com/dashboard')
(3) Sign in using valid credentials /login_check (HTTP_REFERER = 'http://example.com/login')
(4) Redirects to / (default_target_path). I expected redirect to /dashboard instead.

I checked according to DefaultAuthenticationSuccessHandler that use_referer only works if login isn't performed from login_path, which is very strange.

So, is this the expected behavior of the use_referer option?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions