Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 505
didinj Avatar asked Aug 28 '26 07:08

didinj


1 Answers

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
like image 55
dmahapatro Avatar answered Aug 30 '26 07:08

dmahapatro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!