如何知道资源是否在 jsr-196 auth 模块中受到保护?

发布于 2024-12-29 13:32:13 字数 309 浏览 3 评论 0原文

我编写了一个自定义 JSR-196 模块,它结合了多种机制来保护资源。

如果提供身份验证,它会很好地工作。

现在,如果访问受保护的资源并且未提供身份验证,我想将用户重定向到某个登录页面。

我如何知道资源受到保护?我不想重定向不受保护的图像或登录页面本身。我使用 web.xml 来允许不受限制的访问。对于这些页面,发送 AuthStatus.SUCCESS 似乎是显示它们的唯一方法。我宁愿认为我需要发送 AuthStatus.SEND_CONTINUE。我需要一种方法来判断是否需要限制这些访问。

我正在使用 Glassfish 3.1。

I wrote a custom JSR-196 module, which combines multiple mechanisms to protect resources.

It works quite well if authentication is provided.

Now, if a protected resource is accessed and authentication isn't provided, I'd like to redirect my user to some login page.

How can I know that a resource is protected? I don't want to redirect for unprotected images or for the login page itself. I used web.xml to allow unrestricted access to that. For those pages, sending AuthStatus.SUCCESS seems to be the only way to display them. I'd rather think I need to send AuthStatus.SEND_CONTINUE. And I'd need a way to tell if I need to restrict access on those.

I'm using Glassfish 3.1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天邊彩虹 2025-01-05 13:32:13

似乎我以某种方式删除了 requestPolicy.isMandatory() 检查...

这就是神奇的地方,它告诉您资源是否受到保护。

我认为 requestPolicy 与 ServerAuthModule 相关联。现在,这是事实,但为受保护和不受保护的资源创建了不同的 ServerAuthModule。

Seems that I somehow removed the requestPolicy.isMandatory() check...

That's where the magic happens, it tells you if a resource is protected.

I thought requestPolicy was tied to the ServerAuthModule. Now, this is true, but a different ServerAuthModule is created for protected and unprotected resource.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文