Jetty OSGI :用一个 securityHandler 保护所有 servlet



我正在使用 jetty 作为 paxweb 的 osgi 捆绑包。我想确保所有通过OSGI HttpService注册的servlet和资源都由一个通用的安全处理程序保护(此外,我想使用JAASLoginService)。我还想将所有未经身份验证的请求重定向到单个登录页面。

是否可以配置此方案?

如果所有 Servlet 都使用相同的 HttpContext,这是可能的。作为一个带有工作Jaas的运行时容器,我建议使用Apache Karaf。它提供了所需的一切,包括Pax Web作为HTTPService,包括HttpWhiteboard Extender。

看看 Apache Felix 白板 HTTP 支持。只需在注册表中注册筛选器,它们由底层 Jetty: http://felix.apache.org/site/apache-felix-http-service.html

筛选器支持的筛选器服务属性:

pattern - Regular expression pattern to register filter with.
contextId - Id of context to register with.
service.ranking - Where in the chain this filter should be placed.
init.* - Filter initialization values.

我自己还没有尝试过这个,但很快就会...

最新更新