Resteasy安全拦截器 - 如何在拦截器内获取客户端IP地址? [英] Resteasy security interceptor - how to obtain client IP address inside interceptor?

查看:377
本文介绍了Resteasy安全拦截器 - 如何在拦截器内获取客户端IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了一个拦截器,用以下注释对客户端IP地址进行安全检查 -
@Provider
@ServerInterceptor
@Precedence(SECURITY)

I have implemented an interceptor to carry out a security check on the client IP address with the following annotations - @Provider @ServerInterceptor @Precedence("SECURITY")

预处理方法采用参数HttpRequest请求,ResourceMethod方法。
有没有办法从Resteasy HttpRequest对象获取客户端的IP地址?
我可以实现一个过滤器来解决这个问题,但是想在一个地方进行安全检查。

The preprocess method takes the parameters HttpRequest request, ResourceMethod method. Is there a way of obtaining the client's IP address from the Resteasy HttpRequest object? I can implement a filter to get around this, but would like to keep security checks in the one place.

推荐答案

客户端IP地址可从请求对象获得。但是你不能将它用于安全目的,因为它不是每个客户端唯一的:它可能只是最近的代理的地址,甚至是你自己的地址。

The client IP address is available from the request object. But you can't use that for security purposes as it isn't unique per client: it might just be the address of the nearest proxy, even your own.

这篇关于Resteasy安全拦截器 - 如何在拦截器内获取客户端IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆