带 EL 的 Spring 安全注释——需要编译调试信息吗?
我正在考虑为我的应用程序使用 Spring Security 注释以及 EL(表达式语言)功能。例如:
@PreAuthorize("hasPermission(#contact, 'admin')")
public void deletePermission(Contact contact, Sid recipient, Permission permission);
我需要 EL 功能,因为我已经构建了自己的 ACL 实现。然而,要将此功能与“#contact”类型参数一起使用,Spring 文档是这样说的:
您可以访问任何方法 按名称作为表达式的参数 变量,前提是你的代码有 编译的调试信息。
两个问题:
- 这引出了 生产应用商业化 分发其中包含调试信息?
- 如果没有,有什么办法吗 这?
感谢您对此的任何指导!
I am considering using Spring Security annotations for my application, with the EL (expression language) feature. For example:
@PreAuthorize("hasPermission(#contact, 'admin')")
public void deletePermission(Contact contact, Sid recipient, Permission permission);
I need the EL capability because I have built my own ACL implementation. However, to use this capability with the "#contact" type arguments, the Spring documentation says this:
You can access any of the method
arguments by name as expression
variables, provided your code has
debug information compiled in.
This begs two questions:
- It is acceptable to have a
production application commercially
distributed with debug info in it? - If not, is there any way around
this?
Thanks for any guidance on this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
作为解决方法,您可以实现自定义 ParameterNameDiscoverer 用你自己的策略。这是一个生成简单编号名称(
arg0
等)的示例:和配置:
As a workaround you can implement a custom ParameterNameDiscoverer with your own strategy. Here is an example which produces simple numbered names (
arg0
, etc):And configuration:
我想当您第一次解决这个问题时这不是一个选择,但现在您可以这样做
http://docs.spring.io/spring-security/site/docs/current/reference/html /el-access.html#access-control-using-preauthorize-and-postauthorize
I guess this wasn´t an option when you approached the problem the first time, but now you can do this
http://docs.spring.io/spring-security/site/docs/current/reference/html/el-access.html#access-control-using-preauthorize-and-postauthorize
我现在找不到参考资料,但您可能有兴趣知道 Java 8 将始终包含参数名称,即使我相信 Java 8 将始终包含参数名称,即使在调试模式下也是如此。
I can't find the reference now, but you might be interested to know that Java 8 will include parameter names at all times, even when I believe Java 8 will include parameter names at all times, even in debug mode.