Set spring security remember me cookie after login via facebook
Asked Answered
S

1

1

I am building a mobile web app that has the option to login via facebook/twitter. I want the app to remember the login via Spring security's remember me functionality so that the user need to have to login frequently.

I have the parts that will call out to facebook and get the access_token that will identify the user. I can login the user using

    SecurityContextHolder.getContext().setAuthentication(
        new UsernamePasswordAuthenticationToken(principal, credentials, authorities));

I am trying to use similar approach to add remember me functionality by

    RememberMeAuthenticationToken auth = new RememberMeAuthenticationToken(key, principal, authorities);
    SecurityContextHolder.getContext().setAuthentication(auth);

While this logs in the user, it does not set the remember me cookie. What am I missing here?

Thanks!

Sadick answered 16/4, 2013 at 15:58 Comment(0)
D
2

Try to inject the implementation of RememberMeServices interface and then try to do:

rememberMeServices.loginSuccess(request, response, auth);

Be sure that _spring_security_remember_me parameter is present in the request.

Dubitable answered 16/4, 2013 at 16:11 Comment(2)
Does the request with the remember me parameter need to be a POST?Sadick
Also, do I need to write my own implementation of the remember me service?Sadick

© 2022 - 2024 — McMap. All rights reserved.