简体   繁体   English

在grails中禁用默认的可搜索控制器

[英]Disable default searchable controller in grails

Is there a way to disable controller which is a part of some plugin (Searchable in my case) in Grails? 有没有办法禁用Grails中某些插件(在我的情况下为Searchable)的一部分的控制器? The only two ways I can think of are pointing it to 404 page in UrlMappings [1] or writing filter for the same thing. 我能想到的仅有的两种方法是将其指向UrlMappings [1]中的404页面,或为同一件事编写过滤器。 However this seems to me more like a workaround that a proper solution. 但是,在我看来,这更像是一种适当的解决方法。 Also at least in case of Searchable plugin the need to get rid of default controller and view seems quite common to me as they are both basically useless. 至少在使用Searchable插件的情况下,摆脱默认控制器和视图的需求在我看来很常见,因为它们基本上都没有用。

[1] this was also accepted at Disable grails Searchable plugin default search page? [1] 禁用grails可搜索的插件默认搜索页面也接受了此设置?

If you are using spring spring-security-core , than it will be very easy to restrict the controllers. 如果您使用spring spring-security-core ,那么限制控制器将非常容易。

You just need to place the following code in config.groovy 您只需要在config.groovy中放置以下代码

grails.plugins.springsecurity.rejectIfNoRule = true     //Deny all urls by default
grails.plugins.springsecurity.securityConfigType = SecurityConfigType.InterceptUrlMap
grails.plugins.springsecurity.interceptUrlMap = [
/** Start IS_AUTHENTICATED_ANONYMOUSLY block **/
    '/about/**':        ['IS_AUTHENTICATED_ANONYMOUSLY']
        ,'/':               ['IS_AUTHENTICATED_REMEMBERED'] ]

Controllers which are mentioned in the interceptUrlMap block are accessible. 可以访问interceptUrlMap块中提到的控制器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM