15 Mayıs 2020 Cuma

Tomcat tomcat-users.xml

Giriş
Bu dosyanın yolu şöyle.
$CATALINA_HOME/conf/tomcat-users.xml
Dosyanın içi şöyle.
<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">

  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <user username="tomcat" password="123" roles="manager-gui"/>
  <user username="cargo" password="123" roles="manager-script"/>
</tomcat-users>
web.xml dosyasına şu tagler ekleniyor.
<security-constraint>
  ...
</security-constraint>

<security-role>
...
</security-role>
1. Roller
<role> tag'i içine tanımlanır

Örnek
Şöyle yaparız
<role rolename="manager"/>
Örnek
Şöyle yaparız
<role rolename="manager-gui"/>

manager-gui ve manager-script Rolleri
Açıklaması şöyle. Yani 3tane önemli rol var. Bunlar
1. manager-gui
2. manager-status
3. admin-gui
In order to be able to manage the Tomcat server (e.g. to deploy a Java application — .war file, we have to have management access to the Tomcat server. By default, this is disabled, so we have to do it on our own. This means that we have to configure Tomcat for that. Tomcat, in its default configuration, uses role-based authorizations, and it has predefined some of the necessary manager/admin roles for the purpose. So, simply put, what we have to do, is just add a user (defining his/her credentials username, and password, and give him/her those manager/admin roles.
Açıklaması şöyle
To have access to the dashboard the admin user needs the manager-gui role. Later, we will need to deploy a WAR file using Maven, for this, we need the manager-script role too.
manager-gui ile "Manager App" ile uygulamasın erişebiliriz. Manager App için yol şöyledir.
http://localhost:8080/manager/html
Bu ekrana girince deploy işlemi için ekranın en altına gitmek gerekiyor. Açıklaması şöyle.
Scroll to the bottom to the WAR file to deploy section. Click Browse… and select the WAR file from before. Click Deploy.
Ayrıca $CATALINA_BASE/conf/Catalina/localhost/manager.xml içinde Tomcat'a hangi bilgisayarlardan erişilebileceği belirtiliyor. "Manager App" uyuglamasına erişmek için bu xml'deki bilgisayarı kullanmak gerekir.

Örnek
Şöyle yaparız
<role rolename="manager-gui"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>

<user username="super" password="superpassword" 
  roles="admin-gui,manager-gui,manager-status"/>
Örnek
Şöyle yaparız
<role rolename="manager-gui"/>
<role rolename="manager-script"/>

<user username="admin" password="password" roles="manager-gui, manager-script"/>
2. Kullanıcılar
<user> tag'i içine tanımlanır. Kullanı ismi, şifresi ve rolü belirtilir.

Örnek
Şöyle yaparız
<user username="admin" password="admin" roles="manager"/>
Örnek
Şöyle yaparız
<user username="admin" password="admin" roles="manager-gui"/>

Hiç yorum yok:

Yorum Gönder