开发者

Script level login to Grails app using Acegi security

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.

开发者_StackOverflow

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 ?


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)        
  }
  ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜