How to access the tools using wget and token

  Written by The Jahia Team
   Estimated reading time:

Since , security has been improved on /tools by using a token see

Without the token here was the way to access a page using username/password with wget

wget --user=xxx --password=xxx "http://localhost:8080/modules/tools/precompileServlet?compile_type=all&jsp_precompile=true"

What is the way to do it using the token?



The idea is to first access the URL using user/password and save a session cookie. Then this request can be parsed using SED to get the token.

Then as a second request, we use the same session and the token. Here could be an example:

token=$(wget -qO- --user=jahia --password=welcome1 "http://localhost:8080/modules/tools/precompileServlet" --keep-session-cookies --save-cookies cookies.txt |  sed '/toolAccessToken=/,/&/!d;/&/q' |  sed -e 's/^.*\(toolAccessToken=.*\)".*$/\1/')
wget --load-cookies cookies.txt "http://localhost:8080/modules/tools/precompileServlet?compile_type=all&jsp_precompile=true&"$token


Related links