How to access the tools using wget and token

  Written by The Jahia Team
 
Sysadmins
   Estimated reading time:

Since 7.2.3.1 , security has been improved on /tools by using a token see https://www.jahia.com/customers/extranet/digital-experience-manager/upgrade/from-dx-7230-to-dx-7231

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?

 

Answer

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