开发者

Is there a way to get the IP address of the client/caller in a Shiro Filter in Grails

sorry if this is a dumb question. I have some web service calls that are implemented in Grails controllers and we use the Shiro plugin for security. I want to be able to create a whitelist of IP ad开发者_Python百科dresses for certain operations that should only come from our own servers or trusted partners. I am finding the documentation a little spares on this subject. My first thought was to try and implement the whitelist here. I wouldn't be surprised if there is a simpler way to do this. I am a bit of a Shiro newb. Could sure use a copy of Shiro for Dummies!

class ShiroSecurityFilters {
     def filters = {
        all(uri: "/**") {
            before = {
                // Ignore direct views (e.g. the default main index page).
                if (controllerName in ['foo', 'bar']) {
                  return true
                }
                 // Access control by convention.
                accessControl()
            }
        }
    }
}


You should have access to the request object in the Filter and you can call request.getRemoteAddr() to access the IP address.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜