LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-09-2011, 03:29 AM   #1
pmorin
Member
 
Registered: Jun 2011
Posts: 40

Rep: Reputation: Disabled
Question Having a secure folder on Tomcat


Hi !

I have a folder I would like to secure by a password on my Tomcat Server.
On this server, I have Liferay 6 CE and I created a folder "/html/admin" on the Liferay's root folder.
I added a user in tomcat-users.xml and I've been told here that I should add some lines in the web.xml of my application (Liferay in my case).
I'd like to reproduce the behavior we can have with a .htaccess on Apache.

The problem :
When I added the following lines in Liferay's web.xml, the app is not working.
I think the problem comes from the fact that there is already some security constraints in the file, but I don't know how to do what I want : securing /html/admin files by a password without breaking all the Liferay default's configuration.

Here are the lines I added in the web.xml file (between <web-app> tags) :
Code:
<security-constraint>
        <web-resource-collection>
                <web-resource-name>Ressource</web-resource-name>
                <url-pattern>/html/admin/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
                <role-name>admin</role-name>
        </auth-constraint>
</security-constraint>

<login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>Admin Liferay pages</realm-name>
</login-config>

<security-role>
        <description>Securing /html/admin/</description>
        <role-name>admin</role-name>
</security-role>
Can you help me ?


Thanks !
Pit

Last edited by pmorin; 09-09-2011 at 04:08 AM.
 
Old 09-12-2011, 10:49 AM   #2
pmorin
Member
 
Registered: Jun 2011
Posts: 40

Original Poster
Rep: Reputation: Disabled
Nobody knows if we can have several "security-constraint" tags in "web.xml" ?
 
Old 09-15-2011, 09:10 AM   #3
pmorin
Member
 
Registered: Jun 2011
Posts: 40

Original Poster
Rep: Reputation: Disabled
Really ? No one knows ?

Maybe I'm not clear enough. In that case, please, tell me so.
 
Old 09-26-2011, 05:15 AM   #4
pmorin
Member
 
Registered: Jun 2011
Posts: 40

Original Poster
Rep: Reputation: Disabled
You can't have more than one "login-config", so you can't have an ".htaccess like" protected folder on a webapps using a "form" authentication method.
In my case, using Liferay, it's impossible to have a folder protected by "tomcat-users.xml" users.

To achieve what I wanted, I created a new webapp :
webapps/protectedfolders/WEB-INF/web.xml
webapps/protectedfolders/protected/

With webapps/protectedfolders/WEB-INF/web.xml :
Code:
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
    <display-name>protectedfolder</display-name>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Protected files</web-resource-name>
            <url-pattern>/protected/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>

    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>default</realm-name>
    </login-config>

    <security-role>
        <description>Securing protected pages</description>
        <role-name>admin</role-name>
    </security-role>
</web-app>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Session replication using apache+mod_jk+tomcat(5.5.28-veriosn of tomcat) sreejithp Linux - Server 1 12-24-2010 06:46 AM
security holes in FC6 directly effecting a secure installation of apache tomcat jsbali Linux - Security 3 03-12-2007 04:26 PM
TOMCAT init script not working on startup -- tomcat 4.x / Mandrake Linux 8.0 jmartinph Mandriva 0 03-08-2004 01:31 AM
Vsftpd Folder ownerships - Is this secure? Korff Linux - Security 2 06-06-2003 01:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration