didinj
didinj

Reputation: 31

grails spring security rest plugin

I'm trying restful spring security rest plugin from https://github.com/dmahapatro/grails-spring-security-rest-sample.git

I upgrade grails to 2.3.7 and spring security rest to 1.3.4. And all running smoothly.

I'm using postman for testing the rest login.

url: http://localhost:8080/grails-spring-security-rest-sample/api/login form-data: username = user, password = pass

But there's always return error code 400 Bad Request. Is there something wrong with the config or test?

Thanks, Didin

Upvotes: 3

Views: 2054

Answers (1)

dmahapatro
dmahapatro

Reputation: 50245

This is a POST request with content-type as application/json. Refer dev tool again during the call to /api/login, it should be clear.

This is driven by a setting provided by the plugin as below:

grails.plugin.springsecurity.rest.login.useJsonCredentials = true

If you wish to pass it as url param then switch the above off (in the app). By default setting is to use request url parameter as:

//default is true
grails.plugin.springsecurity.rest.login.useRequestParamsCredentials = true

In that case the request could look like:

http://localhost:8080/grails-spring-security-rest-sample/api/login?username=user&password=pass

Parameter name for username and password can also be customized by these settings:

grails.plugin.springsecurity.rest.login.usernameParameter=customusername
grails.plugin.springsecurity.rest.login.passwordParameter=custompassword

Upvotes: 3

Related Questions