{"id":5447,"date":"2012-05-03T14:25:42","date_gmt":"2012-05-03T08:55:42","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=5447"},"modified":"2016-12-19T14:36:46","modified_gmt":"2016-12-19T09:06:46","slug":"restricting-access-to-plugins-classes-with-spring-security","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/restricting-access-to-plugins-classes-with-spring-security\/","title":{"rendered":"Restricting Access To Plugin&#8217;s Classes With Spring Security"},"content":{"rendered":"<p>Many of Grails plugin like  searchable \u00a0and console can prove to be really dangerous if access to their URLs is not blocked. After adding searchable plugin to my  project, I realized that access to its controllers was not defined and was open for all. Now this was a major security concern. There  are many ways of restricting access like doing it manually in filters. But since I am using spring security plugin, there was a better way out. It allows to create mapping (static rules) as configuration for different user roles.<\/p>\n<p>There are different ways of securing url in spring security plugin. And since I am using annotations, I&#8217;ll be defining static rule for annotations only.<\/p>\n<p>[java]<\/p>\n<p>grails.plugins.springsecurity.controllerAnnotations.staticRules = [<\/p>\n<p>&#8216;\/console\/**&#8217;: [&#8216;ROLE_ADMIN&#8217;],<\/p>\n<p>&#8216;\/searchable\/**&#8217;: [&#8216;ROLE_ADMIN&#8217;]<\/p>\n<p>]<\/p>\n<p>[\/java]<\/p>\n<p>By doing this I blocked access for all but ones with the role &#8220;ROLE_ADMIN&#8221; \u00a0for console and searchable controllers.<\/p>\n<div>_________________________________<\/div>\n<div>Hitesh Bhatia<br \/>\nMail,LinkedIn,<a href=\"http:\/\/www.facebook.com\/home.php?#%21\/profile.php?id=100000114437286\" target=\"_blank\">Facebook<\/a>,<a href=\"http:\/\/twitter.com\/d1_ricky\" target=\"_blank\">Twitter<\/a><br \/>\n_________________________________<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Many of Grails plugin like searchable \u00a0and console can prove to be really dangerous if access to their URLs is not blocked. After adding searchable plugin to my project, I realized that access to its controllers was not defined and was open for all. Now this was a major security concern. There are many ways [&hellip;]<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0},"categories":[7],"tags":[350,813,812,326,672,811],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/5447"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=5447"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/5447\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=5447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=5447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=5447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}