Websphere extendedDocumentRoot how to restrict by security role - security

We are using Websphere 8.5.5 Traditional
I have added an extended document root to Websphere's ibm-web-ext.xml file and set file sharing to true.
<fileServingAttribute name="extendedDocumentRoot" value="C:/extdocroot"/>
<enable-file-serving value="true"/>
inside the extended document root folder (C:/extdocroot) is a folder called pdfs. I would like to restrict the pdfs folder to only users who have logged in and have a particular role of 'school'.
the URL to serve up the pdf's is https://domain-name:9080/context-path/pdf/pdf-name.pdf
I added a security constraint in the web.xml file
<security-constraint>
<display-name>school PDFs</display-name>
<web-resource-collection>
<web-resource-name>School PDFs</web-resource-name>
<url-pattern>/pdf/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>school</role-name>
</auth-constraint>
</security-constraint>
No matter what role a user is logged in as the PDF's will get served by the the server. Websphere is ignoring the security constraint for the URL that serves up PDF's from the extended document root. Is it possible to constrain these PDF's by the roles a logged in user has.
Note: My company has asked me to try and put these files outside of the ear file and also have Websphere secure the files using user's role. I was also instructed not to use the Apache HTTP Server to host these files since it is in the DMZ.

I have found that this was a bug in Websphere 8.5.5.11. After upgrading to 8.5.5.12 I was able to add security constraints in the web.xml for folders that were in the extended document root.
I have also tested this in Websphere 9.0.0.5 and everything worked as it should.

Related

Locking down SOLR on ColdFusion 9

This might belong on serverfault, so please move if it does.
We just discovered that you can get to a list of SOLR indexes by going to: http://example.com:8983/solr/ this then allows you access to the SOLR admin for each index. This strikes us as... a bad thing. Luckily though, this is locked down to only be accessbile from a certain IP (our office IP via the firewall), but still means the janitor can get access to our SOLR collections. not ideal.
One way to circumvent it has been to remove the admin folder, however this still allows people access to http://example.com:8983/solr/ which isn't ideal.
I've read through the SOLR documentation on security, but can't seem to fully lock down access to /solr/*. It might be very well a case of looking at the wrong part of the documentation.
Using the code from the documentation:
<security-constraint>
<web-resource-collection>
<web-resource-name>Solr authenticated application</web-resource-name>
<url-pattern>/core1/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>core1-role</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Test Realm</realm-name>
</login-config>
and replacing <url-pattern>/core1/*</url-pattern> with an actual solr collection name does mean that when visiting http://example.com:8983/solr/collection_name/ it will ask me for a login and password, however, when just trying to lock down /solr/* or even * I get no such luck.
I'm using the built in solr that came with CF9
Is this a remote Solr server or is it on the same server as CF9, if on the same server as CF9 then you can just tell Solr to listen on 127.0.0.1. There was a patch for this for CF 9.0.0 back in 2010: http://www.adobe.com/support/security/bulletins/apsb10-04.html
If it is a remote solr server, then you can use your network firewall, or a local firewall (windows firewall or iptables) to limit access to this port (and possibly this server) to only the CF server.

Prevent direct access to composite components by placing them inside /WEB-INF

I'm trying to define some composite components in my web application. According to the tutorials i read, i have to place the xhtml files inside a resource folder located in webcontent.
This solution is problematic, given that it would make those files available for public access from an url.
Is there a way to put this components inside the web-inf folder, and make the jsf look for the files there?
If not, is there another way to avoid direct access?
Thanks.
P.S.: I have looked into this answer, and if i understood BalusC's answer correctly, what I intend to do is possible.
"Composite components" are not exactly the same as "compositions" in the question/answer you found. The OP was clearly talking about compositions as in <ui:include> files which are including <ui:componsition> content.
You effectively want to prevent direct access to /resources. This can be achieved by adding the following security constraint entry to web.xml:
<security-constraint>
<display-name>Restrict direct access to JSF resources</display-name>
<web-resource-collection>
<web-resource-name>JSF resources</web-resource-name>
<url-pattern>/resources/*</url-pattern>
</web-resource-collection>
<auth-constraint /><!-- Empty auth constraint! -->
</security-constraint>
As per the upcoming JSF 2.2, this would not be necessary anymore as it allows you to move the whole /resources folder into /WEB-INF by the following configuration entry in web.xml:
<context-param>
<param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
<param-value>WEB-INF/resources</param-value>
</context-param>

Configure username and password on Tomcat 5.5 application

I have a Tomcat 5.5 server and i deploy a application on it.
I have something like this http://tocatServer:8088/MyApp
I want to limit the acces of users at this address by putting an username and password, but i need help. I know that i must add roles on web.xml, i try it but without success.
If possible i want to send the URL like this
http://username:password#tocatServer:8088/MyApp
This url is sent from a java swing application for getting license from the serlet
Thanks
To restrict the access to a webapp (or to a folder in the webapp URL) in Tomcat:
in webapps/MyApp/WEB-INF/web.xml add
<security-constraint>
<web-resource-collection>
<web-resource-name>
Entire webapp
</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>member</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<!-- pay attention: BASIC in insecure, use it only for test, search for a more secure method -->
<auth-method>BASIC</auth-method>
<realm-name>Text reported when prompting the user for un and pw</realm-name>
</login-config>
and in conf/tomcat-users.xml add
<role rolename="member"/>
<user username="bubi" password="bubi" roles="member"/>
Then reload the webapp and maybe restart Tomcat too.
Source: O'Reilly's Top Ten Tomcat Configuration Tips - 5. Configuring Basic Authentication
About the second question, I don't know how to realize it.

Security Realm for an application within WebSphere 7.0

We are testing using security realms with our web application. In test we will be going against Microsoft Active Directory. Production will go against a custom realm. I have the working great in Tomcat, but can't seem to get this working in WebSphere. I have created a Security Domain (foo-ldap) within WebSphere that can connect to the AD. For now I have applied foo-ldap to the server1 scope. I'm not getting redirected to authenticate.faces when hitting /servlet/LoginServlet.
Web.xml and Tomcat config included below.
Tomcat config:
<Realm className="org.apache.catalina.realm.JNDIRealm"
connectionURL="ldap://ActiveDirectorySrv:389"
connectionName="CN=ldap user,CN=Users,DC=foo,DC=com"
connectionPassword="Password1"
referrals="follow"
userBase="CN=Users,DC=foo,DC=com"
userSearch="(&(objectCategory=user)(sAMAccountName={0}))"
userSubtree="true"
userRoleName="memberOf"
roleBase="CN=Users,DC=foo,DC=com"
roleSubtree="true"
roleName="cn"
roleSearch="(member={0})"/>
Web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/servlet/LoginServlet</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Developers</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/authenticate.faces</form-login-page>
<form-error-page>/loginFailed.faces</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>Developers</role-name>
</security-role>
The issue I was running into was two fold.
The configuration for the security context exists in the web.xml. It must be present the installed war at application install time. We had the config commented out so developers wouldn't need to give credentials when debugging and I was trying to uncomment after deploying the war.
You must map roles to your security realm at install time. We have a script that deploys the applications and without modification, the roles were not mapped and the ability to map roles after install was not available. Even installing from the ibm console site, you have to select detailed install and map groups at install time or the link to map is not available.
Once I got the security installed and the redirect to the login page working, we had one other issue. I'm not sure if this is an issue with our JSF code or not, but I could not redirect to a page that used JSF within WebSphere (works fine with Tomcat). Our solution was to just use a jsp page for the authentication page.
Hope this helps someone else.

Configuring container-managed security in Weblogic

Anyone know of any guides for this? I'm a complete newbie to weblogic and to container-managed security. What I've done already is:
setup an LDAP authenticator in Weblogic
created a simple webapp in Eclipse
Configure web.xml: Added security-constraint, security-role and login-config elements. The realm name used is "myrealm" which already exists in Weblogic. The role name I used is "Admin" which is a global role in Weblogic
Create a simple jsp page "login.jsp". It doesn't actually do any logging in but just a Hello World type of thing. I set this page as form-login-page and form-error-page in login-config in web.xml
Export this webapp to a war file and deploy it in Weblogic
I test it by accessing http://weblogic-server/test/login.jsp, and I expect that I'll be asked to login using an LDAP user first. This doesn't happen, it just shows the Hello World jsp.
I've also tried adding a weblogic.xml to map the "Admin" role to a specific LDAP user (didn't work).
Any advice? It seems there's a lack of online references for this sort of thing (or I don't really know what I should be searching for)
Edit: I've also tried using BASIC auth instead of FORM (no luck)
My web.xml settings are below:
<security-constraint>
<display-name>Test SC</display-name>
<web-resource-collection>
<web-resource-name>Test WR</web-resource-name>
<url-pattern>/hello.jsp</url-pattern>
<http-method>*</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Admin</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>Admin</role-name>
</security-role>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>myrealm</realm-name>
</login-config>
The login page must do some sort of logging in, with the 2 required fields. You have protect the hello_world.jsp page in the web.xml and go to that pages, the login page will be presented.
Edit:
The order is incorrect: it should be security-constraint, login-config and security-role.
Within the web-resource-collection the value of * is invalid for http-method. If you want to protect every method just leave it away.
Note: the server logging whould have hinted the incorrect order of elements in your web.xml.

Resources