Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DX] Ability to authentication a User directly #13062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from

Conversation

norberttech
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #11158
License MIT

Simple usage example:

class LoginController extends ContainerAware
{
    public function loginAction()
    {
        $user = new User('norzechowicz', 'password123');
        $this->container->get('security.login_manager')->loginUser('firewall_name', $user);

        return new Response();
    }
}


<!-- Login Manager -->
<service id="security.login_manager" class="%security.login_manager.class%">
<argument type="service" id="security.context" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the security.authorization_checker and security.token_storage instead? I don't think features should contain deprecated code. From 2.6 on, class names are no longer in parameters for newly added services.

@Koc
Copy link
Contributor

Koc commented Dec 25, 2014

Ref #3137

throw new AuthenticationException("Unauthenticated token");
}

$request = $this->requestStack->getMasterRequest();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would prefer making this service stateless and not inject the requestStack.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this service stateless by passing request in loginUser method argument?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, so the service doesnt dependend on the state of the application (requestStack)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole security component currently depends on the Request(Stack). I don't think this will really matters for now, perhaps for future usage. But what if I want to login from a command? I'd have to fake a Request.

@@ -47,6 +47,8 @@
<parameter key="security.validator.user_password.class">Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator</parameter>

<parameter key="security.expression_language.class">Symfony\Component\Security\Core\Authorization\ExpressionLanguage</parameter>

<parameter key="security.login_manager.class">Symfony\Component\Security\Http\Login\LoginManager</parameter>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use a parameter for the class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.