0
votes

I am trying to use spring security in my application developing restful web services and not getting the way how to send request to j_spring_security_check directly so that i can provide same url as a web service to Authorization of username and password.

Currently i am using following request pattern:

URL: "http://localhost:8080/CabFMS/j_spring_security_check" Content-type: application/x-www-form-urlencoded Body: {'j_username':'user','j_password':'123'}

Response: is Bad credentials

I am not sure about Content-type and body parameters. Please provide suggestion. To send request i am using REST Client

Tarun Gupta

3

3 Answers

1
votes

As you correctly noticed j_spring_security_checks expects application/x-www-form-urlencoded content, therefore you need to encode it as such:

j_username=user&j_password=123
0
votes

Your request pattern should be :

/j_spring_security_check?j_username=user&j_password=123

with method "POST" type.

other then this you can change request action & parameters text "j_spring_security_check" and "j_username" ,"j_password" by configuring alternate text in attributes :

login-processing-url, username-parameter, password-parameter

of spring "form-login" tag in security configuration xml file.

0
votes

Create an AuthenticationSuccessHadler for this, in the authenticationSuccess method, return base64 encoded authorization header with the pattern username:password

Then, on each request, set the header as Basic yourtokenhere