可以使用cURL查看nonce值吗?

问题描述 投票:0回答:1

我根据教程将Google文件选择器添加到我的网站。我在使用代理缓存时遇到了问题。缓存响应在获取

https://apis.google.com/js/googleapis.proxy.js?onload=startup
时会产生内容安全策略 (CSP) 错误。我们从获取开始:
https://content.googleapis.com/static/proxy.html
。回复内容为:

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script nonce="qdLPyo649SRoGa6KMrFo5w">
  window['startup'] = function() {
    googleapis.server.init();
  };
</script>
<script src="https://apis.google.com/js/googleapis.proxy.js?onload=startup" async defer nonce="qdLPyo649SRoGa6KMrFo5w"></script>
</head>
<body>
</body>
</html>

后来的网站向:

https://apis.google.com/js/googleapis.proxy.js?onload=startup
发出请求,如果使用缓存,则会失败。据我了解 CSP 的工作原理,此响应应包含具有
nonce
值的 CSP 标头,但我的故障排除显示它没有它。浏览器执行的请求:

curl 'https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fabc-static%2F_%2Fjs%2Fk%3Dgapi.lb.en.L92w_vMR5kE.O%2Fd%3D1%2Frs%3DAHpOoo-GjmyR8TQVDKPrbqj5UQg7cU3cCA%2Fm%3D__features__' \
  -H 'authority: content.googleapis.com' \
  -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
  -H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' \
  -H 'if-modified-since: Fri, 30 Jun 2023 18:58:00 GMT' \
  -H 'referer: http://localhost:3000/' \
  -H 'sec-ch-ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: iframe' \
  -H 'sec-fetch-mode: navigate' \
  -H 'sec-fetch-site: cross-site' \
  -H 'upgrade-insecure-requests: 1' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' \
  -H 'x-client-data: CJC2yQEIpLbJAQipncoBCEzdygEIlqHLAQiGoMBBCLvIzQEIucrNAQiK080BALzUzQEYj87NAQ==' \
  --compressed

响应头: proxy.html response headers

回复内容:

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script nonce="0dydr7sqTq3pOrRxZ6JvvQ">
  window['startup'] = function() {
    googleapis.server.init();
  };
</script>
<script src="https://apis.google.com/js/googleapis.proxy.js?onload=startup" async defer nonce="0dydr7sqTq3pOrRxZ6JvvQ"></script>
</head>
<body>
</body>
</html>

proxy.js
要求:

curl 'https://apis.google.com/js/googleapis.proxy.js?onload=startup' \
  -H 'sec-ch-ua: "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"' \
  -H 'Referer: https://content.googleapis.com/' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --compressed

proxy.js
响应标头: proxy.js response headers

caching browser proxy nonce content-security-policy
1个回答
0
投票

是的,可以使用

-v
--verbose
,而且它不是唯一的选项,请看这里 如何使用命令行curl 显示请求标头

© www.soinside.com 2019 - 2024. All rights reserved.