限制服务器使用以供内部使用 [英] Restrict server usage for internal use
问题描述
我有一个使用spring MVC的REST Web服务,它是面向外部的。
我想限制访问某些REST调用以获取管理员使用情况以及同一内部网络上的其他服务器进行调用。
I have a REST web service using spring MVC which is external-facing. I would like to restrict access to some REST calls for admin usage and for other servers on the same internal network to call.
到目前为止,我可以想到以下解决方案:
So far I can think of the following solutions:
- 使用Spring-Security限制使用hasIpAddress访问权限映射到子网
- 将敏感的REST调用分离到他们自己的控制器中并编写AOP切入点,该切入点读取HttpServletRequest以获取IP地址并检查白名单
我不喜欢这两种解决方案。 (1)没有给我足够的灵活性,我可能在几个子网上,并且可能只想打开一个IP范围。 (2)几乎完全给我我想要的东西,但看起来很黑,必须有更好的方法来做到这一点。
I'm not fond of either solution. (1) doesn't give me enough flexibility, I may be on several subnets, and may only want to open up an IP range. (2) Gives me nearly exactly what I want but it seems hacky, there must be a better way to do this.
推荐答案
(2)为什么你不想使用@PreAuthrize这样的标准注释。您可以将它们放在方法中,这样就不需要将敏感的REST方法移动到其他控制器。
(2) why do you not want to use the "standard" annotations like @PreAuthrize. You can put them at the methods, so you do not need to move the sensitive REST methods to an other controller.
这篇关于限制服务器使用以供内部使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!