Last active
January 19, 2018 14:27
-
-
Save hferentschik/3cdb226fc3f37be8f427da4323fcbe3e to your computer and use it in GitHub Desktop.
Auth
This file contains hidden or 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
#!/bin/bash | |
USERNAME=$1 | |
PASSWORD=$2 | |
REQUEST=https://auth.prod-preview.openshift.io/api/login?redirect=https%3A%2F%2Fjenkins.prod-preview.openshift.io%2F | |
RESPONSE=response.html | |
COOKIES=cookies.txt | |
TMP_HTML=login.html | |
PROXY="-k --proxy http://localhost:8080" | |
rm $COOKIES 2> /dev/null | |
rm $TMP_HTML 2> /dev/null | |
rm $RESPONSE 2> /dev/null | |
LOGIN_URL=$(curl -s -b $COOKIES -c $COOKIES -L -o $TMP_HTML -w %{url_effective} $REQUEST) | |
# go get github.com/ericchiang/pup to install pup | |
FORM_POST_URL=$(cat login.html | pup 'form attr{action}') | |
echo "Final login URL: $LOGIN_URL" | |
echo "Post form URL: $FORM_POST_URL" | |
echo " " | |
echo "Cookies:" | |
echo "$(cat $COOKIES)" | |
echo " " | |
curl -s -b $COOKIES -c $COOKIES -L \ | |
--data-urlencode "username=$USERNAME" \ | |
--data-urlencode "password=$PASSWORD" \ | |
-d "login=Log+in" \ | |
--referer $LOGIN_URL \ | |
$FORM_POST_URL \ | |
-o $RESPONSE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment