简体   繁体   中英

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? The only two ways I can think of are pointing it to 404 page in UrlMappings [1] or writing filter for the same thing. 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.

[1] this was also accepted at Disable grails Searchable plugin default search page?

If you are using spring spring-security-core , than it will be very easy to restrict the controllers.

You just need to place the following code in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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