在Grails中使用自己的方法扩展SpEL? [英] Extending SpEL with own methods in Grails?
问题描述
我想在Grails应用程序中添加自定义的SpEL方法,就像在,通过覆盖 EvaluationContext 。这将工作吗?
I'd like to add custom SpEL methods in Grails applciation, like it's done for plain Spring-Security application in this question, by overriding EvaluationContext. Will this work?
如何将全局方法安全
插入安全配置?我可以配置安全性,但要在那里添加什么?就像
How do I plug global-method-security
into security config? I can configure security, but what to add there? Something like
grails.plugins.springsecurity = {
'global-method-security' {
'expression-handler' {
ref("myMethodSecurityExpressionHandler")
}
}
}
?但是什么样的代码会解释它?
? But what code will interpret it?
展望 SpringSecurityCoreGrailsPlugin.groovy
也让我没有见解。
推荐答案
仅当您安装了spring-security-acl插件时才可用。它配置 expressionHandler
bean:
This is only available if you also have the spring-security-acl plugin installed. It configures the expressionHandler
bean:
expressionHandler(DefaultMethodSecurityExpressionHandler) {
parameterNameDiscoverer = ref('parameterNameDiscoverer')
permissionEvaluator = ref('permissionEvaluator')
roleHierarchy = ref('roleHierarchy')
trustResolver = ref('authenticationTrustResolver')
}
所以如果你有你自己的子类 DefaultMethodSecurityExpressionHandler
你可以像这样替换
So if you have your own subclass of DefaultMethodSecurityExpressionHandler
you can replace the bean in resources.groovy
like this:
import com.mycompany.myapp.MyMethodSecurityExpressionHandler
beans = {
expressionHandler(MyMethodSecurityExpressionHandler) {
parameterNameDiscoverer = ref('parameterNameDiscoverer')
permissionEvaluator = ref('permissionEvaluator')
roleHierarchy = ref('roleHierarchy')
trustResolver = ref('authenticationTrustResolver')
}
}
这篇关于在Grails中使用自己的方法扩展SpEL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!