BowerStudios.com

  • My Lab
  • Family
  • Friends
  • Professional
  • About
Home

Interacting with a spring-security app from the command line using Curl

daniel —Fri, 02/17/2012 - 12:33pm

  • Programming

If you want to use Curl to interact with a spring-security protected application (like Grails or Spring-Web), the following will do the trick.


$ curl --data "j_username=myusername&j_password=mypassword" http://localhost:8080/springSecurityApp/j_spring_security_check --cookie-jar cookies.txt

Explanation:
This line logs into the app with a username of "myusername" and a password of "mypassword".
The Context of the spring-security protected application is http://localhost:8080/springSecurityApp.
Spring security listens at a controller named j_spring_security_check for those credentials.
Curl will store the cookie from that response in a "cookie-jar", which is just a file named cookies.txt.


$ curl http://localhost:8080/springSecurityApp/api/thing1 --cookie cookies.txt

This second line is our actual api call to the spring-security protected application.
Curl submits the cookie received from the first call.

If you want more output from curl, just append this argument to any call:
--verbose

If you want curl to follow redirects, append this argument:
--location

  • Log in to post comments

Navigation

  • Search
  • Recent content
  • Contact Me
  • Mail
  • Pass Hasher
  • Bower Studios Admin

Quotes

daniel —Fri, 07/01/2011 - 12:51pm

Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration.

—

Stan Kelly-Bootle

  • Log in to post comments
  • daniel's quotes

Popular content

Last viewed:

  • Grails: Calling validate() or save() removes previous errors
  • Determine version and architecture of Debian/Ubuntu installed
  • Run Grails developer mode with AJP
  • Quotes 775
  • Regular Expressions Resources

Copyright 2021 Daniel Bower
  • My Lab
  • Family
  • Friends
  • Professional
  • About