Hello all,

could anybody help how to configure jetty 7.2 to use authentication when
serving some static content with the DefaultServlet?

The content is accessible but access restrictions don't seem to be used.


This is what I tried:

<Configure id="Server" class="org.eclipse.jetty.server.Server">

    <Set name="handler">
      <New id="Handlers"
class="org.eclipse.jetty.server.handler.HandlerCollection">
        <Set name="handlers">
          <Array type="org.eclipse.jetty.server.Handler">
            <Item>
              <New class="org.eclipse.jetty.servlet.ServletContextHandler">
                <Set name="contextPath">/content</Set>
                <Set name="resourceBase">/home/ar/content/</Set>
                <Call name="addServlet">
                  <Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
                  <Arg>/</Arg>
                </Call>
              </New>
            </Item>
          </Array>
        </Set>
      </New>
  </Set>

  <Call name="addBean">
    <Arg>
      <New class="org.eclipse.jetty.security.HashLoginService">
        <Set name="name">UserDatabase</Set>
        <Set name="config"><Property name="jetty.home"
default="."/>/etc/realm.properties</Set>
        <Set name="refreshInterval">0</Set>
      </New>
    </Arg>
  </Call>

</Configure>

and within "etc/webdefault.xml" I added

<web-app>
  <servlet>
    <servlet-name>default</servlet-name>
    <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

  <security-constraint>
    <web-resource-collection>
      <url-pattern>/</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>admin</role-name>
      <role-name>user</role-name>
      <role-name>moderator</role-name>
    </auth-constraint>
  </security-constraint>

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


Thanks for any hints,
Axel.
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to