将 AppEngine 黑名单变成白名单

发布于 2024-09-30 14:03:00 字数 283 浏览 0 评论 0原文

AppEngine 允许定义黑名单,以禁止来自某些 IP 范围的访问 (http://code.google.com/appengine/docs/python/config/dos.html)。

我想做的是相反的:白名单,只允许从某些 IP 范围进行访问。

我不是一个网络专家,所以我希望得到一些帮助: 如果我想限制对 130.100.120.0 到 130.100.123.255 范围内的 IP 的访问,可以使用 AppEngines 黑名单机制来完成,还是应该从我的应用程序内部进行检查?

谢谢。

AppEngine allows the definition of blacklists, to disallow access from certain IP Ranges (http://code.google.com/appengine/docs/python/config/dos.html).

What I would like to do is the inverse: A whitelist, that only allows access from certain IP Ranges.

I am not much of a network specialist, so I would appreciate some help:
If I wanted to limit access to IPs in the Range from 130.100.120.0 to 130.100.123.255, could that be done using AppEngines blacklist mechanism, or should I do the checking from within my application?

Thanks.

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

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

发布评论

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

评论(2

笔落惊风雨 2024-10-07 14:03:00

不,AppEngine 黑名单功能(此处记录了 的作用更多是为了防止拒绝服务攻击等,因此,包含黑名单 IP 的文件最多可以包含 100 个 IP。因此,黑名单

似乎 并不是真正用于工业强度的访问控制。您唯一的选择是在您的应用程序中进行检查。

No, the AppEngine blacklist functionality (which is documented here serves more to prevent denial of service attacks and so on. So, the file containing blacklisted IPs can, at most, contain 100 IPs. Thus, the blacklist isn't really intended for industrial strength access control.

Given this, it seems your only option is to do the checking within your application.

怀中猫帐中妖 2024-10-07 14:03:00

创建 Servlet 过滤器。像这样的东西:

public void doFilter(ServletRequest req, ServletResponse res,
                     FilterChain chain) throws IOException, ServletException {

    // replace with your custom IP checking
    if (!req.getRemoteAddr().equals("127.0.0.1")) {
        HttpServletResponse response = (HttpServletResponse) servletResponse;

        // send any response 
        response.sendError(404);
    }

    filterChain.doFilter(req, res);
}

Create a Servlet Filter. Something like this:

public void doFilter(ServletRequest req, ServletResponse res,
                     FilterChain chain) throws IOException, ServletException {

    // replace with your custom IP checking
    if (!req.getRemoteAddr().equals("127.0.0.1")) {
        HttpServletResponse response = (HttpServletResponse) servletResponse;

        // send any response 
        response.sendError(404);
    }

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