console « Intelligrape Groovy & Grails Blogs

Posts Tagged ‘ console ’

Grails Console, execute from file.

Posted by on September 7th, 2012

Grails Console is one of the most useful plugins available, it provides a console to application to which it’s installed. This plugin can be used to test code snippets amazingly fast, debug app, create patches and scripts.

And the latest update has made it even more fantastic. Now it has an option to execute code from a file. All one needs to do is specify the path and it will run code snippet from that file. Now this is of extreme use because, I used to store my scripts in files for later use. And now I don’t have to copy paste code every time, I can just specify absolute path of the file and it will do rest for me.

Sample Image below shows path of the file as “/home/hitesh/scriptFile” this is the file with the code.
And on the right side, the output screen shows code that was in file and its output below.

Grails Console 1.2

_________________________________
Hitesh Bhatia
Mail LinkedIn,Facebook,Twitter
_________________________________
Posted in Grails, Groovy, Plugin

Restricting Access To Plugin’s Classes With Spring Security

Posted by on May 3rd, 2012

Many of Grails plugin like searchable  and 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.

There are different ways of securing url in spring security plugin. And since I am using annotations, I’ll be defining static rule for annotations only.


grails.plugins.springsecurity.controllerAnnotations.staticRules = [

'/console/**': ['ROLE_ADMIN'],

'/searchable/**': ['ROLE_ADMIN']

]

By doing this I blocked access for all but ones with the role “ROLE_ADMIN”  for console and searchable controllers.

_________________________________
Hitesh Bhatia
Mail,LinkedIn,Facebook,Twitter
_________________________________
Posted in Grails