瀏覽代碼

no message

BF-202308171519\Administrator 2 年之前
父節點
當前提交
b19cbdce68

+ 0 - 0
kxs-system/kxs-system-biz/src/main/java/com/kxs/system/biz/security/KxsUserDetailsServiceImpl.java → kxs-common/kxs-common-security/src/main/java/com/kxs/common/security/service/KxsUserDetailsServiceImpl.java


+ 0 - 0
kxs-system/kxs-system-biz/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports → kxs-system/kxs-system-api/src/main/java/com/kxs/system/api/feign/RemoteUserService.java


+ 0 - 83
kxs-system/kxs-system-biz/src/main/java/com/kxs/system/biz/event/SysLogListener.java

@@ -1,83 +0,0 @@
-//package com.kxs.system.biz.event;
-//
-//import cn.hutool.core.util.StrUtil;
-//import com.fasterxml.jackson.annotation.JsonFilter;
-//import com.fasterxml.jackson.databind.ObjectMapper;
-//import com.fasterxml.jackson.databind.ser.FilterProvider;
-//import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
-//import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
-//import com.kxs.common.core.jackson.SkyJavaTimeModule;
-//import com.kxs.common.log.config.SkyLogProperties;
-//import com.kxs.common.log.event.SysLogEvent;
-//import com.kxs.common.log.event.SysLogEventSource;
-//import com.kxs.system.api.feign.RemoteLogService;
-//import com.kxs.system.api.model.SysLog;
-//import com.kxs.system.biz.service.SysLogService;
-//import lombok.RequiredArgsConstructor;
-//import lombok.SneakyThrows;
-//import lombok.extern.slf4j.Slf4j;
-//import org.springframework.beans.BeanUtils;
-//import org.springframework.beans.factory.InitializingBean;
-//import org.springframework.boot.context.properties.EnableConfigurationProperties;
-//import org.springframework.context.event.EventListener;
-//import org.springframework.core.annotation.Order;
-//import org.springframework.scheduling.annotation.Async;
-//import org.springframework.stereotype.Component;
-//
-//import java.util.Objects;
-//
-//
-///**
-// * 异步监听日志事件
-// *
-// * @author 没秃顶的码农
-// * @date 2023/10/28
-// */
-//@Slf4j
-//@RequiredArgsConstructor
-//@Component
-//@EnableConfigurationProperties(SkyLogProperties.class)
-//public class SysLogListener implements InitializingBean {
-//
-//	// new 一个 避免日志脱敏策略影响全局ObjectMapper
-//	private final static ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-//
-//	private final SysLogService remoteLogService;
-//
-//	private final SkyLogProperties logProperties;
-//
-//	@SneakyThrows
-//	@Async
-//	@Order
-//	@EventListener(SysLogEvent.class)
-//	public void saveSysLog(SysLogEvent event) {
-//		SysLogEventSource source = (SysLogEventSource) event.getSource();
-//		SysLog sysLog = new SysLog();
-//		BeanUtils.copyProperties(source, sysLog);
-//
-//		// json 格式刷参数放在异步中处理,提升性能
-//		if (Objects.nonNull(source.getBody())) {
-//			String params = OBJECT_MAPPER.writeValueAsString(source.getBody());
-//			sysLog.setParams(StrUtil.subPre(params, logProperties.getMaxLength()));
-//		}
-//		log.info("保存日志:{}", sysLog);
-//        remoteLogService.saveLog(sysLog);
-//	}
-//
-//	@Override
-//	public void afterPropertiesSet() {
-//		OBJECT_MAPPER.addMixIn(Object.class, PropertyFilterMixIn.class);
-//		String[] ignorableFieldNames = logProperties.getExcludeFields().toArray(new String[0]);
-//
-//		FilterProvider filters = new SimpleFilterProvider().addFilter("filter properties by name",
-//				SimpleBeanPropertyFilter.serializeAllExcept(ignorableFieldNames));
-//		OBJECT_MAPPER.setFilterProvider(filters);
-//		OBJECT_MAPPER.registerModule(new SkyJavaTimeModule());
-//	}
-//
-//	@JsonFilter("filter properties by name")
-//	class PropertyFilterMixIn {
-//
-//	}
-//
-//}

+ 0 - 134
kxs-system/kxs-system-biz/src/main/java/com/kxs/system/biz/security/KxsRemoteRegisteredClientRepository.java

@@ -1,134 +0,0 @@
-//package com.kxs.system.biz.security;
-//
-//import cn.hutool.core.util.BooleanUtil;
-//import cn.hutool.core.util.StrUtil;
-//import com.kxs.common.core.constant.CacheConstants;
-//import com.kxs.common.core.constant.SecurityConstants;
-//import com.kxs.system.api.model.SysOauthClientDetails;
-//import com.kxs.system.biz.service.SysOauthClientDetailsService;
-//import jakarta.annotation.Resource;
-//import lombok.RequiredArgsConstructor;
-//import lombok.SneakyThrows;
-//import org.springframework.cache.annotation.Cacheable;
-//import org.springframework.context.annotation.Configuration;
-//import org.springframework.security.oauth2.core.AuthorizationGrantType;
-//import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
-//import org.springframework.security.oauth2.core.OAuth2Error;
-//import org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationCodeRequestAuthenticationException;
-//import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
-//import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;
-//import org.springframework.security.oauth2.server.authorization.settings.ClientSettings;
-//import org.springframework.security.oauth2.server.authorization.settings.OAuth2TokenFormat;
-//import org.springframework.security.oauth2.server.authorization.settings.TokenSettings;
-//import org.springframework.stereotype.Component;
-//
-//import java.time.Duration;
-//import java.util.Arrays;
-//import java.util.Optional;
-//
-///**
-// * 查询客户端相关信息实现
-// *
-// * @author 没秃顶的码农
-// * @date 2022/5/29
-// */
-//@RequiredArgsConstructor
-//public class KxsRemoteRegisteredClientRepository implements RegisteredClientRepository {
-//
-//	/**
-//	 * 刷新令牌有效期默认 30 天
-//	 */
-//	private final static int REFRESH_TOKEN_VALIDITY_SECONDS = 60 * 60 * 24 * 30;
-//
-//	/**
-//	 * 请求令牌有效期默认 12 小时
-//	 */
-//	private final static int ACCESS_TOKEN_VALIDITY_SECONDS = 60 * 60 * 12;
-//
-//	@Resource
-//	private SysOauthClientDetailsService clientDetailsService;
-//
-//	/**
-//	 * Saves the registered client.
-//	 *
-//	 * <p>
-//	 * IMPORTANT: Sensitive information should be encoded externally from the
-//	 * implementation, e.g. {@link RegisteredClient#getClientSecret()}
-//	 * @param registeredClient the {@link RegisteredClient}
-//	 */
-//	@Override
-//	public void save(RegisteredClient registeredClient) {
-//	}
-//
-//	/**
-//	 * Returns the registered client identified by the provided {@code id}, or
-//	 * {@code null} if not found.
-//	 * @param id the registration identifier
-//	 * @return the {@link RegisteredClient} if found, otherwise {@code null}
-//	 */
-//	@Override
-//	public RegisteredClient findById(String id) {
-//		throw new UnsupportedOperationException();
-//	}
-//
-//	/**
-//	 * Returns the registered client identified by the provided {@code clientId}, or
-//	 * {@code null} if not found.
-//	 * @param clientId the client identifier
-//	 * @return the {@link RegisteredClient} if found, otherwise {@code null}
-//	 */
-//
-//	/**
-//	 * 重写原生方法支持redis缓存
-//	 *
-//	 * @param clientId 客戶端
-//	 * @return 注册客户
-//	 */
-//	@Override
-//	@SneakyThrows
-////	@Cacheable(value = CacheConstants.CLIENT_DETAILS_KEY, key = "#clientId", unless = "#result == null")
-//	public RegisteredClient findByClientId(String clientId) {
-//
-//		SysOauthClientDetails clientDetails = clientDetailsService.getClientDetailsById(clientId);
-//		if(clientDetails == null){
-//			throw new OAuth2AuthorizationCodeRequestAuthenticationException(
-//					new OAuth2Error("客户端查询异常,请检查数据库链接"), null);
-//		}
-//
-//		RegisteredClient.Builder builder = RegisteredClient.withId(clientDetails.getClientId())
-//			.clientId(clientDetails.getClientId())
-//			.clientSecret(SecurityConstants.NOOP + clientDetails.getClientSecret())
-//			.clientAuthenticationMethod(ClientAuthenticationMethod.CLIENT_SECRET_BASIC);
-//
-//		for (String authorizedGrantType : clientDetails.getAuthorizedGrantTypes()) {
-//			builder.authorizationGrantType(new AuthorizationGrantType(authorizedGrantType));
-//
-//		}
-//		// 回调地址
-//		Optional.ofNullable(clientDetails.getWebServerRedirectUri())
-//			.ifPresent(redirectUri -> Arrays.stream(redirectUri.split(StrUtil.COMMA))
-//				.filter(StrUtil::isNotBlank)
-//				.forEach(builder::redirectUri));
-//
-//		// scope
-//		Optional.ofNullable(clientDetails.getScope())
-//			.ifPresent(scope -> Arrays.stream(scope.split(StrUtil.COMMA))
-//				.filter(StrUtil::isNotBlank)
-//				.forEach(builder::scope));
-//
-//		return builder
-//			.tokenSettings(TokenSettings.builder()
-//				.accessTokenFormat(OAuth2TokenFormat.REFERENCE)
-//				.accessTokenTimeToLive(Duration.ofSeconds(
-//						Optional.ofNullable(clientDetails.getAccessTokenValidity()).orElse(ACCESS_TOKEN_VALIDITY_SECONDS)))
-//				.refreshTokenTimeToLive(Duration.ofSeconds(Optional.ofNullable(clientDetails.getRefreshTokenValidity())
-//					.orElse(REFRESH_TOKEN_VALIDITY_SECONDS)))
-//				.build())
-//			.clientSettings(ClientSettings.builder()
-//				.requireAuthorizationConsent(!BooleanUtil.toBoolean(clientDetails.getAutoapprove()))
-//				.build())
-//			.build();
-//
-//	}
-//
-//}