Search code examples
grailsshiro

Grails Shiro plugin, unauthorized redirect missing context path


Just started working with the Grails Shiro plugin for Grails 4.0.2 and have hit a little problem which I suspect is probably a config error on my part. The unauthorized redirect, i.e., the URL the user is redirected to if not authorized, does not appear to take account of the context path defined for the application (in server.servlet.context-path in application.groovy). So, for example, for my 'myapp' app, it's coming up with http://localhost:8090/auth/login?targetUri=/myapp/mycontroller/myaction instead of http://localhost:8090/myapp/auth/login?targetUri=/myapp/mycontroller/myaction. I can work round this, I'm sure, but is there somewhere I can configure this so it works correctly?


Solution

  • The problem is a bug in the ShiroGrailsExceptionResolver which relies on the UrlMappingUtils to create the "forwardUrl". If we were doing a forward this would work, but we're doing a redirect which relies on the context-path.

    This should be fixed shortly thanks to, I presume your, bug report https://github.com/nerdErg/grails-shiro/issues/16

    (and sorry for the delay)

    I have just release v4.3 an 3.3 which fix this problem.