August 30, 2008, 08:35:15 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Revenue sharing launched. This is offered as a "thank you" for being a member of webmasterstalks.com community! If you have an Adsense/Yahoo publisher account then you can start right away !
 
  Home   Forum   Help Search Directory Calendar Login Register    RSS 2.0 feedAtom feed


News
Revenue sharing launched. This is offered as a "thank you" for being a member of webmasterstalks.com community! If you have an Adsense/Yahoo publisher account then you can start right away !
Pages: [1]
  Print  
Author Topic:

setting a Basic authentication on a Tomcat

 (Read 1485 times)
0 Members and 1 Guest are viewing this topic.
bostam
Jr. Member
**

Points: 1
Offline Offline

Posts: 55


« on: August 20, 2006, 11:31:00 »

Hi,

 Is anoyone set an auth over a Tomcat ? I just trying to do that and I cannot find aby solution.


Thank you very much !
Logged


TheGodFather
Administrator
Hero Member
*****

Points: 202
Offline Offline

Posts: 2570



WWW
« Reply #1 on: August 20, 2006, 14:18:01 »

That depends by what connector you are using. It can be done in several ways. Tell us if you are using a connector and I will try to tell you how to set up the basic auth

Regards
Logged

bostam
Jr. Member
**

Points: 1
Offline Offline

Posts: 55


« Reply #2 on: August 23, 2006, 23:58:02 »

I use Proxy connector through apache and mod_jk2 for other site. I found some info but not clear enough ...

Thanks
Logged
TheGodFather
Administrator
Hero Member
*****

Points: 202
Offline Offline

Posts: 2570



WWW
« Reply #3 on: August 25, 2006, 18:15:19 »

For Tomcat Basic Uath System you need to do 2 steps:

Insert in the <Engine...></Engine> tag of your server configuration this tag:
<Realm className="org.apache.catalina.realm.MemoryRealm">
</Realm>

Edit (or create) the conf/tomcat-users.xml file where you will place the name of all the users you wanna give access to. A conf is like this:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="test"/>
  <user username="user" password="pass" roles="test"/>
</tomcat-users>

Second simply adding to your web application descriptor (web.xml) some imformation like, for example:

  <security-constraint>
    <web-resource-collection>
      <web-resource-name>
        My Protected WebSite
      </web-resource-name>

      <url-pattern> /* </url-pattern>
      <http-method> GET </http-method>
      <http-method> POST </http-method>
    </web-resource-collection>
    <auth-constraint>
    <!-- the same like in your tomcat-users.conf file -->
      <role-name> test </role-name>
    </auth-constraint>
  </security-constraint>
   <login-config>
    <auth-method> BASIC </auth-method>
    <realm-name>  Basic Authentication </realm-name>
  </login-config>
  <security-role>
    <description> Test role </description>
    <role-name> test </role-name>
  </security-role>


Anyway if you use proxy system you can doit from apache in this way:

<Proxy>
        Options ExecCGI

        AllowOverride AuthConfig
        Order Allow,Deny
        Allow From All

        AuthName "sms-Gw Access"
        AuthType Basic
        AuthUserFile /var/www/etc/htpasswd
        require valid-user
</Proxy>

This second method is not suitable for mod_jk2

I hope this helps !

Regards

Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks

TinyPortal v0.9.7 © Bloc
Valid XHTML 1.0! Valid CSS!