我想使用curl命令取消部署tomcat的一些战争。但是由于CSRF令牌而出现错误

时间:2019-05-17 07:00:48

标签: tomcat curl

我遇到的错误:

  403 Access Denied
  style type="textcss"
    !--
    BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
    H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
    PRE, TT {border: 1px dotted #525D76}
    A {color : black;}A.name {color : black;}
    --
  style

 body
   h1403 Access Deniedh1

    You are not authorized to view this page.


    By default the Manager is only accessible from a browser running on the
    same machine as Tomcat. If you wish to modify this restriction, you'll need
    to edit the Manager's ttcontext.xmltt file.


    If you have already configured the Manager application to allow access and
    you have used your browsers back button, used a saved book-mark or similar
    then you may have triggered the cross-site request forgery (CSRF) protection
    that has been enabled for the HTML interface of the Manager application. You
    will need to reset this protection by returning to the
    a href="managerhtml"main Manager pagea. Once you
    return to this page, you will be able to continue using the Manager
    application's HTML interface normally. If you continue to see this access
    denied message, check that you have the necessary permissions to access this
    application.


    If you have not changed
    any configuration files, please examine the file
    ttconftomcat-users.xmltt in your installation. That
    file must contain the credentials to let you use this webapp.


    For example, to add the ttmanager-guitt role to a user named
    tttomcattt with a password of tts3crettt, add the following to the
    config file listed above.

pre
<role rolename="manager-gui">
<user username="tomcat" password="s3cret" roles="manager-gui">
pre

    Note that for Tomcat 7 onwards, the roles required to use the manager
    application were changed from the single ttmanagertt role to the
    following four roles. You will need to assign the role(s) required for
    the functionality you wish to access.

    ul
      littmanager-guitt - allows access to the HTML GUI and the status
          pagesli
      littmanager-scripttt - allows access to the text interface and the
          status pagesli
      littmanager-jmxtt - allows access to the JMX proxy and the status
          pagesli
      littmanager-statustt - allows access to the status pages onlyli
    ul

    The HTML interface is protected against CSRF but the text and JMX interfaces
    are not. To maintain the CSRF protection:

   ul
    liUsers with the ttmanager-guitt role should not be granted either
        the ttmanager-scripttt or ttmanager-jmxtt roles.li
    liIf the text or jmx interfaces are accessed through a browser (e.g. for
        testing since these interfaces are intended for tools not humans) then
        the browser must be closed afterwards to terminate the session.li
   ul

    For more information - please see the
    a href="docsmanager-howto.html"Manager App HOW-TOa.

 body

谁能告诉我如何禁用CSRF令牌?因为我无法在web.xml文件中找到它

1 个答案:

答案 0 :(得分:0)

只需从apache-tomcat/wepapps/manager/WEB-INF/web.xml删除此框即可:

<filter-mapping>
  <filter-name>CSRF</filter-name>
  <servlet-name>HTMLManager</servlet-name>
</filter-mapping>

要通过脚本而不是使用Web浏览器提交命令,您的Manager用户帐户需要manager-script permission role

然后,您可以使用脚本工具友好的/text界面(由Web浏览器友好的/html安装)来使用以下格式发布任何supported manager commands

http://{host}:{port}/manager/text/{command}?{parameters}

为了在运行于本地主机端口8080的Tomcat上undeplay the /examples application上,您需要以下网址:

http://localhost:8080/manager/text/undeploy?path=/examples