-
-
Save pbnj/b7fe74c0540290de59a35446b9e7dd74 to your computer and use it in GitHub Desktop.
Wrapper to fetch CSRF token and authenticate via the login page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Wrapper to fetch CSRF token and authenticate via the login page | |
url='http://localhost:3002' | |
login="${url}/sign_in" | |
curl -sS -c cookies.txt "$login" | | |
htmlstar sel -t -v "//_:input[@name='csrf_token']/@value" -o ' | |
' | xargs -I{} curl -sS -c cookies.txt -b cookies.txt "$login" \ | |
--data-urlencode 'user[email][email protected]' \ | |
--data-urlencode 'user[password]=password' \ | |
--data-urlencode 'csrf_token={}' \ | |
-o /dev/null | |
curl -sS -b cookies.txt -c cookies.txt "$url" -o /dev/null \ | |
-w '%{http_code}\n' | xargs test 200 -eq \ | |
&& printf 'Logged in.\n' 1>&2 | |
tmux send "c -b cookies.txt -c cookies.txt ${url}/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment