Functions: adds httpie helpers for xsrf
The functions are wrappers around http and https and set the x-xsrf-token header based on the value of the Xsrf-token cookie in the session file. Currently, the cookie name and header name are hard coded. I may look to specify those in an argument at some point although for now it's probably fine.
This commit is contained in:
parent
e99566de7f
commit
02b9b6e51e
1 changed files with 14 additions and 0 deletions
|
@ -325,3 +325,17 @@ function cat(){
|
||||||
/usr/bin/bat "$@"
|
/usr/bin/bat "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# These functions extend httpie in order to add an X-XSRF-TOKEN header based on the value of a cookie.
|
||||||
|
http-xsrf(){
|
||||||
|
sessionfile="$(echo "$*" | grep -Eo -- '--session[= ][^ ]*' | sed 's/^--session[= ]//')"
|
||||||
|
cookie="$(jq -r '.cookies."XSRF-TOKEN".value' "$sessionfile")"
|
||||||
|
http "$@" "X-XSRF-TOKEN:$cookie"
|
||||||
|
}
|
||||||
|
|
||||||
|
https-xsrf(){
|
||||||
|
sessionfile="$(echo "$*" | grep -Eo -- '--session[= ][^ ]*' | sed 's/^--session[= ]//')"
|
||||||
|
cookie="$(jq -r '.cookies."XSRF-TOKEN".value' "$sessionfile")"
|
||||||
|
https "$@" "X-XSRF-TOKEN:$cookie"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue