0
votes

I have the following scenario: I have a secured area of my domain under the pattern "/register", for which I have associated a fixed user called "registrant", with the unique role USER_REGISTRANT. The relevant security.yml sections are:

providers:
    in_memory:
        memory:
            users:
                registrant: { password: registrant, roles: 'REGISTERING_USER' }

firewalls:
    register:
        pattern: ^/register/.*
        anonymous: false
        form_login:
            login_path: /register/initiate_registration
            check_path: /register/start_registration

My goal is the following: whenever the user tries to enter the "/register" security context, she should be automatically authenticated as the user "registrant", without any form interaction or other user-side authentication steps.

I want to achieve this using the standard form-login mechanisms in Symfony2, i.e. when the user is sent to the login_path, the system should simply generate the necessary token/form data and pass it to check_path, just as would be done if the user had filled in a form and submitted it.

The general outline of the logic should go something like this:

/**
 * @Route("/register/initiate_registration", name="initiate_registration")
 */
public function startAction() {

    // TODO: Generate form data etc here

    return $this->redirect($this->generateUrl('start_registration'));
}

What steps should be taken in the login_path controller in order to get the functionality desired above?

1

1 Answers

1
votes

Is this docs can be usefull for you security?