How does Grails spring security rememberMe on custom auth?

I use grails spring security with a custom auth method for facebook authentication:

def auth() {
    ...
}

When I check the cookie in my browser I can see that the cookie lifetime is finished when the browser session is closed. The persistent rememberMe cookie is set only if I use the default login/auth action from the plugin.

What do I have to change such that the user which is loggedin with my custom auth method is not logged out between sessions?

For reauthentication I use:

def success() {

    // get facebook user data

    springSecurityService.reauthenticate username

    if(springSecurityService.loggedIn) {
            // do something

    }
}

How do I set the rememberMe cookie?

Answers


Idea: let the spring security remember me service know it should consider the successful login.

  1. In your facebook success action, upon successful authentication, do the following:

    //wire remember me services
    def rememberMeServices
    
    //... in your action:
    springSecurityService.reauthenticate username
    
    def authentication = SecurityContextHolder.context.authentication
    rememberMeServices.loginSuccess(request, response, authentication)
    
  2. in your Config.groovy, add the following

    grails.plugins.springsecurity.rememberMe.alwaysRemember = true
    

Need Your Help

Looking how to use Functions with Functions, using prototype

javascript

I'm just kind of horsing around, trying to mimick certain jQuery functions (trying to write the vanilla javascript for the jQuery functions) I've made up this here

Jenkins slave using an ssh gateway

ssh proxy jenkins

I have jenkins running on master.com, and want to have a slave running on slave.com. However, to ssh to the slave I need to go through gateway.com. Generally to ssh to this machine from my normal

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.