blackuprise
blackuprise

Reputation: 450

Grails scaffolding only for admin users?

I'm wondering is there a way to isolate scaffolding to be available only to admin users and implement my views for viewing domains in Grails? Anyone have idea how to do that?

Regards, Mika

Upvotes: 1

Views: 1326

Answers (2)

chrislovecnm
chrislovecnm

Reputation: 2611

I would expand on the solution that OverZealous proposed. I would use Spring Security and also install the templates.

See: Template Documentation

These are the templates that the scaffolding uses to generate the controllers and views. You can modify the templates to include the Spring Security annotations that OverZealous recommended.

Upvotes: 1

OverZealous
OverZealous

Reputation: 39570

If you use something like Spring Security Core, you can simply define your scaffolding controllers with a security restriction, like any other controller.

Annotation-based Example:

@Secured(['ROLE_ADMIN'])
class WidgetController {
    static scaffold = true
}

Alternatively, if you use the InterceptMap style, you might put this in your Config.groovy

grails.plugins.springsecurity.interceptUrlMap = [
   '/widget/**':    ['ROLE_ADMIN'],
   '/sprocket/**':  ['ROLE_ADMIN'],
   ...
]

Upvotes: 0

Related Questions