I'm using Spring MVC, Tiles and Shiro.
This is how my unauthorizedUrl property is configured:
<property name="unauthorizedUrl" value="/unauthorized"/>
My expectation is that when MyAuthorizingRealm
finds invalid credentials, that Shiro will redirect to /unauthorized
.
But, that doesn't happen for me on form submission. I have a login @Controller
that is mapped to handle GET and POST actions for /login
. For accesses to the url /lists
the login form is displayed. So it seems to work in one case but not the other.
@Controller
@RequestMapping(value = "/login")
public class LoginController {
@RequestMapping(method = RequestMethod.GET)
public String getLoginFormView(Model model) {
return "login";
}
// if this method doesn't exist a Post not supported exception is thrown
@RequestMapping(method = RequestMethod.POST)
public String handlePost() {
return "this view doesn't exist";
}
}
Even if I throw AuthenticationException
from MyAuthorizingRealm.doGetAuthenticationInfo()
I still can't get Shiro to redirect to /unauthorized
. It always ends up continuing with the filter chain and executes the POST method in the @Controller
; and of course I expect a redirect instead.
Here is my webapp-context.xml
:
http://pastebin.com/XZaCKqEC
And here is my web.xml
:
http://pastebin.com/5H81Tm8A
Following is some TRACE log output from Shiro. Shiro works when you try to access /lists
. But, when the login form is submitted the redirect to /unauthorized
never happens. Note, the login submission is detected:
http://pastebin.com/ZEK3CTdJ
So, the login submission is detected but the original filter chain is executed anyway instead of redirecting to /unauthorized
I'm stumped. Many thanks for any help and if you need more info please let me know.