配置文件
[filters]
rememberAuthFilter = com.kanq.shiro.filter.RememberAuthenticationFilter
rememberAuthFilter.loginUrl = /platform/login
logout.redirectUrl = /platform/login
[urls]
/platform/doLogin = anon
/platform/login/captcha = anon
/platform/login/logout = anon
/assets/** = anon
/** = anon
/platform/** = rememberAuthFilter
代码是
public class RememberAuthenticationFilter extends FormAuthenticationFilter {
@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
if (isLoginRequest(request, response)) {
return true;
} else {
Subject subject = getSubject(request, response);
// If principal is not null, then the user is known and should be allowed access.
return subject.getPrincipal() != null;
}
}
@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
System.out.println("###########################################################################");
saveRequestAndRedirectToLogin(request, response);
return false;
}
}
我没登录的时候输入的路径是/platform/home ,代码是
@At("")
@Ok("beetl:/home.html")
@RequiresAuthentication
public void home(HttpServletRequest req) {
}
返回到的是登陆页面 但是onAccessDenied貌似没有进入,我的理解应该是要进入这个方法的。。我理解有误? 那onAccessDenied这个什么情况才会触发呢。。
另外我输入/platform/sys/user/add可以进入添加用户页面,代码如下
@At("/add")
@Ok("beetl:/base/user/add.html")
public void add() {
}
是因为没有添加 @RequiresAuthentication标签的原因吗?