需求是当用户没有登录状态,发送请求重定向到登录页面,登录页面不唯一,根据请求地址决定
10 回复
@wendal
配置了
authc = org.nutz.integration.shiro.SimpleAuthenticationFilter
authc.loginUrl = /demo/login
入口方法注解了@RequiresUser
重写了FormAuthenticationFilter中的onAccessDenied(),但是拦截不到,请求后先跳转了/user/login
并没有配置/user/login,这是nutz默认的吗
#authc = org.nutz.integration.shiro.SimpleAuthenticationFilter
#authc.loginUrl = /console/login
#logout.redirectUrl = /console/login
[filters]
myForm = net.demo.common.shiro.filter.MyFormAuthenticationFilter
[urls]
/* = anon
/user/** = myForm
public class MyFormAuthenticationFilter extends FormAuthenticationFilter{
@Override
protected boolean onAccessDenied(ServletRequest request,
ServletResponse response, Object mappedValue) throws Exception {
System.out.println("MyFormAuthenticationFilter-------------onAccessDenied");
HttpServletRequest httpReq = (HttpServletRequest) request;
System.out.println("isAccessAllowed-url:"+httpReq.getRequestURL());
return false;
}
}
这样不走authc,请求后还是先跳转了/user/login再进入onAccessDenied()的
@qq_8af2c940 贴日志
来自炫酷的 NutzCN
2016-08-24 11:07:50,670 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:92) DEBUG - Found mapping for [GET] path=/jingwang/user/addOrder/lvb : CourseModule.commitCourseOrder(CourseModule.java:104)
2016-08-24 11:07:50,673 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'courseModule'<class net.eluxue.modules.controllers.web.CourseModule>
2016-08-24 11:07:50,674 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:178) DEBUG - >> Load definition name=courseModule
2016-08-24 11:07:50,674 org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:161) DEBUG - Found IocObject(courseModule) in AnnotationIocLoader(packages=[net.eluxue])
2016-08-24 11:07:50,674 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:208) DEBUG - >> Make...'courseModule'<class net.eluxue.modules.controllers.web.CourseModule>
2016-08-24 11:07:50,675 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:70) DEBUG - Load class net.eluxue.modules.controllers.web.CourseModule without AOP
2016-08-24 11:07:50,675 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:59) DEBUG - Save object 'courseModule' to [app]
2016-08-24 11:07:50,676 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'courseLvbService'<class net.eluxue.modules.services.CourseLvbService>
2016-08-24 11:07:50,676 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:178) DEBUG - >> Load definition name=courseLvbService
2016-08-24 11:07:50,676 org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:161) DEBUG - Found IocObject(courseLvbService) in AnnotationIocLoader(packages=[net.eluxue])
2016-08-24 11:07:50,676 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:208) DEBUG - >> Make...'courseLvbService'<class net.eluxue.modules.services.CourseLvbService>
2016-08-24 11:07:50,677 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:70) DEBUG - Load class net.eluxue.modules.services.CourseLvbService without AOP
2016-08-24 11:07:50,677 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:59) DEBUG - Save object 'courseLvbService' to [app]
2016-08-24 11:07:50,677 org.nutz.service.EntityService.<init>(EntityService.java:40) DEBUG - Get TypeParams for self : net.eluxue.modules.models.CourseLvb
2016-08-24 11:07:50,677 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'dao'<>
2016-08-24 11:07:50,677 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'courseVodService'<class net.eluxue.modules.services.CourseVodService>
2016-08-24 11:07:50,677 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:178) DEBUG - >> Load definition name=courseVodService
2016-08-24 11:07:50,677 org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:161) DEBUG - Found IocObject(courseVodService) in AnnotationIocLoader(packages=[net.eluxue])
2016-08-24 11:07:50,678 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:208) DEBUG - >> Make...'courseVodService'<class net.eluxue.modules.services.CourseVodService>
2016-08-24 11:07:50,678 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:70) DEBUG - Load class net.eluxue.modules.services.CourseVodService without AOP
2016-08-24 11:07:50,678 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:59) DEBUG - Save object 'courseVodService' to [app]
2016-08-24 11:07:50,678 org.nutz.service.EntityService.<init>(EntityService.java:40) DEBUG - Get TypeParams for self : net.eluxue.modules.models.CourseVod
2016-08-24 11:07:50,678 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'dao'<>
2016-08-24 11:07:50,678 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'orderService'<class net.eluxue.modules.services.OrderService>
2016-08-24 11:07:50,678 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:178) DEBUG - >> Load definition name=orderService
2016-08-24 11:07:50,678 org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:161) DEBUG - Found IocObject(orderService) in AnnotationIocLoader(packages=[net.eluxue])
2016-08-24 11:07:50,678 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:208) DEBUG - >> Make...'orderService'<class net.eluxue.modules.services.OrderService>
2016-08-24 11:07:50,678 org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:70) DEBUG - Load class net.eluxue.modules.services.OrderService without AOP
2016-08-24 11:07:50,678 org.nutz.ioc.impl.ScopeContext.save(ScopeContext.java:59) DEBUG - Save object 'orderService' to [app]
2016-08-24 11:07:50,679 org.nutz.service.EntityService.<init>(EntityService.java:40) DEBUG - Get TypeParams for self : net.eluxue.modules.models.Orders
2016-08-24 11:07:50,679 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'dao'<>
2016-08-24 11:07:50,679 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:151) DEBUG - Get 'dao'<interface org.nutz.dao.Dao>
MyFormAuthenticationFilter-------------onAccessDenied
isAccessAllowed-url:http://192.168.1.35/user/login
@wendal 威武!已解决,谢谢了!
添加回复
请先登陆