springboot webflux security 在filter中获取用户名

     exchange.getSession().
                subscribe(webSession -> {
                    Object spring_security_context = webSession.getAttribute("SPRING_SECURITY_CONTEXT");
                    if (Optional.ofNullable(spring_security_context).isPresent()) {
                        SecurityContextImpl securityContext = (SecurityContextImpl) spring_security_context;
                        log.info("url:{} method:{} username:{}", exchange.getRequest().getPath(), exchange.getRequest().getMethod(), securityContext.getAuthentication().getName());
                    }
                });

  

posted on 2022-11-03 15:33  知了不了了之  阅读(346)  评论(0编辑  收藏  举报