简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM