Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8741587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:20:34+00:00 2026-06-13T11:20:34+00:00

I am working on a springMVC project in which the user authentication is based

  • 0

I am working on a springMVC project in which the user authentication is based on spring security.

the idea is to have a mobile (android) application to be able to send some sort of data to backend.

So before get my hand dirty into android developing I decided to mock the situation of login form using cURL.

the login form in our site is as following :

http://localhost:8080/app/user/login

and I use following command :

curl -F 'username=admin&password=admin' http://localhost:8080/app/user/login

but yet I will get login page in other words I am not able to pass user authentication based on a mock up situation.

just to note : for every request the spring secure will create a randomize token something similar to :

8863F732ADDE24CD167F4EF502A4333D

how should I pass login form based on spring security using mock situation (either cURL or HTTPClient)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:20:35+00:00Added an answer on June 13, 2026 at 11:20 am

    Use cURL like this:

     curl -d j_username=admin -d j_password=admin -L http://localhost:8080/app/j_spring_security_check
    

    CSRF

    If you get something like Expected CSRF token not found. Has your session expired? that means that CSRF token protection is enabled. To test it with cURL you need a cookie and a CSRF token itself.

    The following command will write all cookies to a file named cookie and print out the CSRF token. Spring Security default token parameter name is _csrf, if you’ve changed it then you need to change grep csrf also.

    curl --cookie-jar cookie -L http://localhost:8080/app/j_spring_security_check  | grep csrf
    

    Then you can execute next command which will pass all cookies from file. Don’t forget to replace |your_token_value| with an actual value which is printed out by the previous command (and _csrf parameter name if you’ve changed it).

    curl --cookie cookie -d "j_username=admin&j_password=admin&_csrf=|your_token_value|" -L http://localhost:8080/app/j_spring_security_check
    

    From Spring Security 3.x to 4.x

    Note that in Spring Security 4.x default value for login-processing-url changed from /j_spring_security_check to POST /login, default value for username-parameter changed from j_username to username and default value for password-parameter changed from j_password to password. If an application explicitly provides these attributes, no action is required for the migration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a web application which is based on spring MVC. We
I'm currently working a project which based on spring MVC, it's just a standard
I'm working on a Spring MVC project in which I'm using Hibernate Validator to
I'm working on project which has the following structure: DaoService - is Spring bean
I am working on a spring mvc web application, in which I am using
I am working on a spring MVC project, from which I need to access
I am working on Spring MVC project in Eclipse Juno. I have a few
I'm working on a Spring MVC 3 web application, I have some JSPs that
I'm working on a Spring MVC project, and I have unit tests for all
I'm working on a Java web application (Adobe Flex front-end, JPA/Hibernate/BlazeDS/Spring MVC backend) and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.