views:

187

answers:

1

Scenario: I have a Grails app that uses Acegi security for authentication. I'm implementing a REST service endpoint in the app and want to be able to GET and POST to / from the service endpoint using a shell script.

I've been trying to use curl to do this, but can't find the right combination of parameters to make the curl command log in to the Grails app; I keep getting the login page back whenever I try a GET or POST.

I know I could change the Grails app security settings to open up the specific service endpoint URLs so that they don't require authentication, but I'd rather not do this; anyone know how to make the authentication work with curl, or an alternative approach ?

+2  A: 

Your login URL would be '/j_spring_security_check' with the username field 'j_username' and the password field 'j_password'. You will want to modify the index method of the Login controller to allow you to redirect to your target URL. Something like:

def index = {
  if (isLoggedIn() && params.redirectUri)
      redirect(uri: redirectUri, params: params)        
  }
  ...
}
Eric Hauser