From 3556c604f9f03de94b0f86e4705e7dccc2441094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Wed, 29 Sep 2021 21:36:41 +0800 Subject: [PATCH] =?UTF-8?q?enhance:=E6=94=B9=E8=BF=9B=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/_posts/shiro-spring.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_posts/shiro-spring.md b/source/_posts/shiro-spring.md index 8f85b49..d1cc9e5 100644 --- a/source/_posts/shiro-spring.md +++ b/source/_posts/shiro-spring.md @@ -342,7 +342,7 @@ public class UsernameRealm extends AuthoringRealm { protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { var token = (UsernamePasswordToken) authenticationToken; return memberRepository.findMemberByUsername((String) token.getPrincipal()) - .map(member -> new SimpleAuthenticationInfo(member, member.getPassword(), member.getFulLName())) + .map(member -> new SimpleAuthenticationInfo(member.getUsername(), member.getPassword(), "UsernameRealm")) .orElseThrow(() -> new AuthenticationException("用户不存在。")); } } @@ -406,7 +406,7 @@ public class TokenRealm extends AuthorizingRealm { // 在BearerToken中,无论是principal还是crendentials里保存的都是用户令牌信息 return storeRepository.findTokenById(token.getToken()) .filter(t -> t.getExpires().isAfter(LocalDateTime.now())) - .map(t -> new SimpleAuthenticationInfo(t.getMember(), t.getToken(), t.getMember().getFulLName())) + .map(t -> new SimpleAuthenticationInfo(t.getMember().getUsername(), t.getToken(), "TokenRealm")) .orElseThrow(() -> new AuthenticationException("用户令牌不存在。")); } }