From 24a3ed7a27f73c88594d2d982278a37f804e04ee Mon Sep 17 00:00:00 2001 From: twilight0620 Date: Mon, 18 Jul 2022 11:40:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0authentication=E5=85=B7?= =?UTF-8?q?=E4=BD=93=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../website/config/ClientWebSecurityConfigurer.java | 3 +-- .../java/org/edgegallery/website/controller/JwtServer.java | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/edgegallery/website/config/ClientWebSecurityConfigurer.java b/src/main/java/org/edgegallery/website/config/ClientWebSecurityConfigurer.java index 115f3f9..e7545d2 100644 --- a/src/main/java/org/edgegallery/website/config/ClientWebSecurityConfigurer.java +++ b/src/main/java/org/edgegallery/website/config/ClientWebSecurityConfigurer.java @@ -96,7 +96,7 @@ public class ClientWebSecurityConfigurer extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.GET, "/mecm-inventory/inventory/v1/mechosts").permitAll() .antMatchers(HttpMethod.GET, "/health").permitAll().antMatchers("/webssh").permitAll() .antMatchers("/wsserver/**").permitAll().anyRequest().authenticated().and() - .addFilterBefore(oauth2ClientAuthenticationProcessingFilter(), ExceptionTranslationFilter.class).logout() + .addFilterAfter(new AuthentionSuccessFilter(), ExceptionTranslationFilter.class).logout() .addLogoutHandler(new LogoutHandler() { @Override public void logout(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, @@ -114,7 +114,6 @@ public class ClientWebSecurityConfigurer extends WebSecurityConfigurerAdapter { /** * oauth2ClientAuthenticationProcessingFilter. */ - @Bean public OAuth2ClientAuthenticationProcessingFilter oauth2ClientAuthenticationProcessingFilter() { LOGGER.info("oauth2ClientAuthenticationProcessingFilter in."); OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter("/login"); diff --git a/src/main/java/org/edgegallery/website/controller/JwtServer.java b/src/main/java/org/edgegallery/website/controller/JwtServer.java index 72351ea..8320fd6 100644 --- a/src/main/java/org/edgegallery/website/controller/JwtServer.java +++ b/src/main/java/org/edgegallery/website/controller/JwtServer.java @@ -16,6 +16,8 @@ package org.edgegallery.website.controller; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; @@ -26,16 +28,18 @@ import org.springframework.stereotype.Component; @Component public class JwtServer { + private static final Logger LOGGER = LoggerFactory.getLogger(JwtServer.class); @Autowired TokenStore jwtTokenStore; public OAuth2AccessToken getToken(String token) { - return jwtTokenStore.readAccessToken(token); + return jwtTokenStore.readAccessToken(token); } public OAuth2AuthenticationDetails getAuthDetails() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + LOGGER.info("authentication is {} type", authentication.getClass().getName()); return (OAuth2AuthenticationDetails) authentication.getDetails(); } } -- Gitee