Я хочу снять войну с кота, используя команду curl.Но получаю ошибку из-за токена CSRF - PullRequest
1 голос
/ 17 мая 2019

Ошибка, которую я получаю:

  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 Ответ

1 голос
/ 17 мая 2019

Вы можете отключить CSRF, просто удалив этот элемент из apache-tomcat/wepapps/manager/WEB-INF/web.xml:

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

Но это не обязательно, потому что для отправки команд через скрипт вместо использования веб-браузера ваш менеджерДля useraccount требуется manager-script роль разрешения .

. Затем вы можете использовать дружественный /text интерфейс инструмента-скрипта, дружественный для веб-браузера /html, для выдачи любого из поддерживаемые команды менеджера с использованием этого формата:

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

Чтобы удалить приложение / examples на Tomcat, работающем на локальном порте 8080, вам нужно запросить этот URL:

http://localhost:8080/manager/text/undeploy?path=/examples
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...