Grails 1.3.5 and Spring Security Core -


i have build grails application, on login redirects users different urls based on user's role (custom roles defined in roles domain). trying integrate spring security core grails plugin application, plan use plugin's domain model.

i understand auth action in logincontroller user login validation , if user logged in redirects default target uri. question how can know if logging in user of type role_admin or role_user or other role? how can check authority here , redirect different uris?

i know how user validation done i.e. how & username , password validated against database in spring security?

thank you. jay chandran.

the redirect happens in org.springframework.security.web.authentication.savedrequestawareauthenticationsuccesshandler plugin extends class in org.codehaus.groovy.grails.plugins.springsecurity.ajaxawareauthenticationsuccesshandler support ajax logins.

if want customize redirect location based on roles, i'd subclass ajaxawareauthenticationsuccesshandler , override onauthenticationsuccess(). you'll have access authentication, can inspect granted authorities , determine go based on those.

then replace plugin's bean yours in resources.groovy:

import org.codehaus.groovy.grails.plugins.springsecurity.springsecurityutils  beans = {    authenticationsuccesshandler(myauthenticationsuccesshandler) {       def conf = springsecurityutils.securityconfig        requestcache = ref('requestcache')       redirectstrategy = ref('redirectstrategy')       defaulttargeturl = conf.successhandler.defaulttargeturl       alwaysusedefaulttargeturl = conf.successhandler.alwaysusedefault       targeturlparameter = conf.successhandler.targeturlparameter       ajaxsuccessurl = conf.successhandler.ajaxsuccessurl       usereferer = conf.successhandler.usereferer    } } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -