How to pass objects from interceptor to controller in Grails 3+

Kevin Tan
1 min readSep 11, 2019

--

Typically in Grails 3, you have the option to not code the security layer using Grails Spring Security, and just write an interceptor to check for user roles to allow a user to access a particular endpoint. However the ways to pass an object from the interceptor to controller was not documented, so here I am writing this down so that I won’t forget.

In your interceptor

request.setAttribute(‘objectName’, object)

In your controller, access the object by using

request.objectName

--

--

Kevin Tan

Full Stack Software Developer in Android, Ionic, JVM & Web. Owner of Double Edge Technologies. https://doubleedgetech.xyz