如何在 DropWizard Auth 中获取 HttpServletRequest @Context

jdh*_*502 5 dropwizard

我在 Dropwizard 0.8 中使用基本身份验证,我需要访问我的 SimpleAuthenticator 类中的请求上下文,超出基本凭据。

也许我需要我自己的 AuthFactory 实现来做到这一点?

我想根据请求的资源路径为 Basic Auth 实现基本访问控制。

谢谢

乔恩

Nas*_*sir 0

我没有使用过 0.8,但在 0.9+ 中,您可以使用@Auth@PermitAll来控制哪些资源有身份验证,哪些资源没有。这样还不能满足你的要求吗?或者您更喜欢更细粒度的控制?

这是 0.9 中 auth 的变更集。您可以参考Dropwizard:BasicAuth示例代码。