关于Shiro的 表单认证

最近有个项目需要,采用安全认证控件。 原本想用SS,刚好看到网友在讨论一个新的安全框架。Apache Shiro,看了一下官方文档,觉得还不错。 干脆就一试。 发现,还有很多小细节,官网没有给出。可能是刚刚从JSecurity接手,也刚出到1.2,还没有太多资源。

在此,根据本项目实践。 将这个新的安全框架中遇到的问题。一一罗列。 仅供参考。

今天发现,采用Form 过滤器认证,需要采用“POST”方法,这个是启动表单认证的条件。在源码中有写到。


/**
174 * This default implementation merely returns <code>true</code> if the request is an HTTP <code>POST</code>,
175 * <code>false</code> otherwise. Can be overridden by subclasses for custom login submission detection behavior.
176 *
177 * @param request the incoming ServletRequest
178 * @param response the outgoing ServletResponse.
179 * @return <code>true</code> if the request is an HTTP <code>POST</code>, <code>false</code> otherwise.
180 */
181 @SuppressWarnings({"UnusedDeclaration"})
182 protected boolean isLoginSubmission(ServletRequest request, ServletResponse response) {
183 return (request instanceof HttpServletRequest) && WebUtils.toHttp(request).getMethod().equalsIgnoreCase(POST_METHOD);
184 }
185



Shiro的登录默认页为login.jsp ,成功登录跳转页面为"/",退出登录,只需要指定该路径为logout过滤器即可。 这些也可以在ini配置中修改。

[main]
authc.successUrl=/content.html
authc.loginUrl=/log.jsp
[users]
admin= admin

[urls]
/index.html = anon
/logout=logout
/** = authc

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值