NutzCN Logo
问答 nutzbook shiro登陆问题,来看看啦
发布于 3321天前 作者 Lewe© 3325 次浏览 复制 上一个帖子 下一个帖子
标签: shiro

1.png

2015-09-27 20:33:03,763 org.nutz.ioc.impl.NutIoc.get(NutIoc.java:145) DEBUG - Get 'dao'<interface org.nutz.dao.Dao>
2015-09-27 20:33:03,784 org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:212) DEBUG - SELECT * FROM pb_user WHERE login_name=? LIMIT 0, 1
| 1 |
|-------|
| admin |
For example:> "SELECT * FROM pb_user WHERE login_name='admin' LIMIT 0, 1 "
2015-09-27 20:33:03,829 org.apache.shiro.realm.AuthenticatingRealm.getAuthenticationInfo(AuthenticatingRealm.java:569) DEBUG - Looked up AuthenticationInfo [1] from doGetAuthenticationInfo
2015-09-27 20:33:03,829 org.apache.shiro.realm.AuthenticatingRealm.cacheAuthenticationInfoIfPossible(AuthenticatingRealm.java:507) DEBUG - AuthenticationInfo caching is disabled for info [1]. Submitted token: [org.nutz.integration.shiro.CaptchaUsernamePasswordToken - admin, rememberMe=false (127.0.0.1)].
2015-09-27 20:33:03,833 org.apache.shiro.authc.credential.SimpleCredentialsMatcher.equals(SimpleCredentialsMatcher.java:95) DEBUG - Performing credentials equality check for tokenCredentials of type [org.apache.shiro.crypto.hash.SimpleHash and accountCredentials of type [org.apache.shiro.crypto.hash.SimpleHash]
2015-09-27 20:33:03,833 org.apache.shiro.authc.credential.SimpleCredentialsMatcher.equals(SimpleCredentialsMatcher.java:101) DEBUG - Both credentials arguments can be easily converted to byte arrays. Performing array equals comparison
2015-09-27 20:33:03,834 org.apache.shiro.web.servlet.SimpleCookie.addCookieHeader(SimpleCookie.java:226) DEBUG - Added HttpServletResponse Cookie [rememberMe=deleteMe; Path=/lms; Max-Age=0; Expires=Sat, 26-Sep-2015 12:33:03 GMT]

12 回复

密码错或加密算法错

@wendal 我也出了这个问题,但是我的账号和密码肯定是匹配的,密码我是写死的一个,用作测试,传值的时候就传那个固定值,用户名是获取的,跟代码了,是一样的,但还是认证不通过,我对比之前的代码(上一个项目用过shiro,正在线上跑,肯定是好用的),只有realmName的值是不同的,nutz的shiro的realmName是
nutzdao_realm,我之前的项目的realmName是com.broadeast.service.impl.RealmService_0。麻烦您看看是什么原因,谢啦~

检查一下验证码的name

来自炫酷的 NutzCN

@wendal 我不是很明白您说的验证码name是哪个?我这边传递的参数有 用户名、密码,还有一个获取的realmName

那把shiro.ini贴一下

来自炫酷的 NutzCN

[main]
sha256Matcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher
nutzdao_realm = com.kdf.cloud.module.mvc.RealmService
nutzdao_realm.credentialsMatcher = $sha256Matcher

authc = org.nutz.integration.shiro.CaptchaFormAuthenticationFilter

[urls]
/login/* = anon
/person/* = authc
/user/logout = logout

@bycuimiao CaptchaFormAuthenticationFilter

这个是要求带验证码的

来自炫酷的 NutzCN

@wendal 那麻烦问下有没有不要求带验证码的过滤器啊,我们的业务暂时没用那么复杂,只需要用到shiro一些基本的功能

那就改成shiro自带的org.apache.shiro.web.filter.authc.FormAuthenticationFilter

Realm的token类型要跟着变一下

@wendal 我试试,谢谢您的帮助

@wendal 抱歉,还要打扰您一下,我实在是搞不定,

这是我的认证方法,现在不考虑业务逻辑,能认证通过就行,您说了验证码,但我看nutzbook里面也只是拿验证码做下逻辑的校验,现在不考虑逻辑,您觉着怎么写我的方法能认证通过呢?

/**
	 * 认证方法
	 */
	@Override
	protected AuthenticationInfo doGetAuthenticationInfo(
			AuthenticationToken token) throws AuthenticationException {
		CaptchaUsernamePasswordToken upToken = (CaptchaUsernamePasswordToken) token;
		
        SimpleAccount account = new SimpleAccount(upToken.getPrincipal(), upToken.getCredentials(), getName());
        return account;
	}

[main]
sha256Matcher = org.apache.shiro.authc.credential.Sha256CredentialsMatcher
nutzdao_realm = com.kdf.cloud.module.mvc.RealmService
nutzdao_realm.credentialsMatcher = $sha256Matcher

authc = org.nutz.integration.shiro.CaptchaFormAuthenticationFilter

[urls]
/login/* = anon
/person/* = authc
/user/logout = logout

Realm的token类型要跟着变一下

不需要验证码就别用CaptchaFormAuthenticationFilter.

添加回复
请先登陆
回到顶部