Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

demo-rbac-security的JwtAuthenticationFilter中,是不是没有对密码进行验证? #222

Unanswered
iscooool asked this question in Q&A
Discussion options

代码只对username进行了验证,是因为验证username就能保证安全了吗?

if (StrUtil.isNotBlank(jwt)) {
 try {
 String username = jwtUtil.getUsernameFromJWT(jwt);
 UserDetails userDetails = customUserDetailsService.loadUserByUsername(username);
 UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
 authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
 SecurityContextHolder.getContext().setAuthentication(authentication);
 filterChain.doFilter(request, response);
 } catch (SecurityException e) {
 ResponseUtil.renderJson(response, e);
 }
 } else {
 ResponseUtil.renderJson(response, Status.UNAUTHORIZED, null);
 }
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /