diff --git a/mystyle-cloud-admin-manager/src/main/resources/application.yml b/mystyle-cloud-admin-manager/src/main/resources/application.yml index 5fa0203..732bd69 100644 --- a/mystyle-cloud-admin-manager/src/main/resources/application.yml +++ b/mystyle-cloud-admin-manager/src/main/resources/application.yml @@ -57,6 +57,7 @@ mapper: mystyle: security: open-api: + - / - /login - /favicon.ico # 开放FAVICON - /system/** @@ -76,6 +77,9 @@ verification-code: type: mysql expiration-time: 300 redis-key: redis-29b9f4ddcf8072d2f856a67f76957821 +logging: + file: + name: ./logs/mystyle-cloud-admin-manager.log management: endpoints: web: @@ -84,4 +88,9 @@ management: endpoint: health: show-details: ALWAYS - enabled: true \ No newline at end of file + enabled: true +info: + version: 1.0 + name: mystyle-cloud-admin-manager + author: zhangmeng + blog: 47.104.229.92:3000 \ No newline at end of file diff --git a/mystyle-cloud-admin-monitor/pom.xml b/mystyle-cloud-admin-monitor/pom.xml index 4c42d7f..979d004 100644 --- a/mystyle-cloud-admin-monitor/pom.xml +++ b/mystyle-cloud-admin-monitor/pom.xml @@ -77,5 +77,12 @@ 2.2.4.RELEASE + + + de.codecentric + spring-boot-admin-server-ui + + + \ No newline at end of file diff --git a/mystyle-cloud-blog/src/main/resources/application.yml b/mystyle-cloud-blog/src/main/resources/application.yml index 738fbc6..8924897 100644 --- a/mystyle-cloud-blog/src/main/resources/application.yml +++ b/mystyle-cloud-blog/src/main/resources/application.yml @@ -66,4 +66,8 @@ management: endpoint: health: show-details: ALWAYS - enabled: true \ No newline at end of file + enabled: true +logging: + file: + name: ./logs/mystyle-cloud-blog.log + level: debug \ No newline at end of file diff --git a/mystyle-cloud-canal/src/main/resources/application.yml b/mystyle-cloud-canal/src/main/resources/application.yml index b6e96b1..24fc585 100644 --- a/mystyle-cloud-canal/src/main/resources/application.yml +++ b/mystyle-cloud-canal/src/main/resources/application.yml @@ -23,4 +23,7 @@ canal: host: 127.0.0.1 port: 11111 userName: canal - password: canal \ No newline at end of file + password: canal +logging: + file: + name: ./logs/mystyle-cloud-canal.log \ No newline at end of file diff --git a/mystyle-cloud-fiction/src/main/resources/application.yml b/mystyle-cloud-fiction/src/main/resources/application.yml index 635b34f..0c040d1 100644 --- a/mystyle-cloud-fiction/src/main/resources/application.yml +++ b/mystyle-cloud-fiction/src/main/resources/application.yml @@ -68,4 +68,7 @@ management: endpoint: health: show-details: ALWAYS - enabled: true \ No newline at end of file + enabled: true +logging: + file: + name: ./logs/mystyle-cloud-fiction.log \ No newline at end of file diff --git a/mystyle-cloud-file/src/main/resources/application.yml b/mystyle-cloud-file/src/main/resources/application.yml index 329448e..b14ac13 100644 --- a/mystyle-cloud-file/src/main/resources/application.yml +++ b/mystyle-cloud-file/src/main/resources/application.yml @@ -77,4 +77,7 @@ management: endpoint: health: show-details: ALWAYS - enabled: true \ No newline at end of file + enabled: true +logging: + file: + name: ./logs/mystyle-cloud-file.log \ No newline at end of file diff --git a/mystyle-cloud-gateway/src/main/resources/application.yml b/mystyle-cloud-gateway/src/main/resources/application.yml index 86bfc21..749421c 100644 --- a/mystyle-cloud-gateway/src/main/resources/application.yml +++ b/mystyle-cloud-gateway/src/main/resources/application.yml @@ -93,3 +93,6 @@ management: health: show-details: ALWAYS enabled: true +logging: + file: + name: ./logs/mystyle-cloud-gateway.log \ No newline at end of file diff --git a/mystyle-cloud-mail/src/main/resources/application.yml b/mystyle-cloud-mail/src/main/resources/application.yml index 20b3c57..5ef06bc 100644 --- a/mystyle-cloud-mail/src/main/resources/application.yml +++ b/mystyle-cloud-mail/src/main/resources/application.yml @@ -72,4 +72,7 @@ management: endpoint: health: show-details: ALWAYS - enabled: true \ No newline at end of file + enabled: true +logging: + file: + name: ./logs/mystyle-cloud-mail.log \ No newline at end of file diff --git a/mystyle-cloud-mq/pom.xml b/mystyle-cloud-mq/pom.xml index c658324..e669e4c 100644 --- a/mystyle-cloud-mq/pom.xml +++ b/mystyle-cloud-mq/pom.xml @@ -10,12 +10,25 @@ 4.0.0 mystyle-cloud-mq + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + - org.springframework.boot - spring-boot-starter-web + com.zhangmeng + mystyle-cloud-api + 1.0-SNAPSHOT diff --git a/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/config/ResourceServerConfig.java b/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/config/ResourceServerConfig.java new file mode 100644 index 0000000..e68a54f --- /dev/null +++ b/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/config/ResourceServerConfig.java @@ -0,0 +1,92 @@ +package com.zhangmeng.mq.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.http.HttpMethod; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; +import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; +import org.springframework.security.oauth2.provider.token.TokenStore; +import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; +import org.springframework.security.oauth2.provider.token.store.JwtTokenStore; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.stream.Collectors; + +/** + * @author 转身的背影在心底里沉沦 + * @date 2021年9月14日16:45:29 + * @version 1.0 + */ +@Configuration +@EnableResourceServer +@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)// 激活方法上的PreAuthorize注解 +public class ResourceServerConfig extends ResourceServerConfigurerAdapter { + + // 公钥 + private static final String PUBLIC_KEY = "public.key"; + + @Autowired + private SecurityProperty securityProperty; + + /*** + * 定义JwtTokenStore + * @param jwtAccessTokenConverter + * @return + */ + @Bean + public TokenStore tokenStore(JwtAccessTokenConverter jwtAccessTokenConverter) { + return new JwtTokenStore(jwtAccessTokenConverter); + } + + /*** + * 定义JJwtAccessTokenConverter + * @return + */ + @Bean + public JwtAccessTokenConverter jwtAccessTokenConverter() { + JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); + converter.setVerifierKey(getPubKey()); //秘钥的一部分 + return converter; + } + /** + * 获取非对称加密公钥 Key + * @return 公钥 Key + */ + private String getPubKey() { + Resource resource = new ClassPathResource(PUBLIC_KEY); + try { + InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream()); + BufferedReader br = new BufferedReader(inputStreamReader); + return br.lines().collect(Collectors.joining("\n")); + } catch (IOException ioe) { + return null; + } + } + + /*** + * SpringSecurity + * Http安全配置,对每个到达系统的http请求链接进行校验 + * @param http + * @throws Exception + */ + @Override + public void configure(HttpSecurity http) throws Exception { + + http.headers().frameOptions().disable(); + + // 所有请求必须认证通过 + http.authorizeRequests() + // 跨域预检请求 + .antMatchers(HttpMethod.OPTIONS, "/**").permitAll() + .antMatchers(securityProperty.getOpenApi()).permitAll() + .anyRequest(). + authenticated(); // 其他地址需要认证授权 + } +} diff --git a/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/config/SecurityProperty.java b/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/config/SecurityProperty.java new file mode 100644 index 0000000..ce378c2 --- /dev/null +++ b/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/config/SecurityProperty.java @@ -0,0 +1,79 @@ +package com.zhangmeng.mq.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * @author 转身的背影在心底里沉沦 + * @date 2021年9月14日16:50:47 + * @version 1.0 + * */ +@Configuration +@ConfigurationProperties("mystyle.security") +public class SecurityProperty { + + /** + * 超级管理员不认证 + * */ + private boolean superAuthOpen; + + /** + * 不验证权限用户名 + * */ + private String superAdmin; + + /** + * 记住密码标识 + * */ + private String rememberKey; + + /** + * 开放接口列表 + * */ + private String[] openApi; + + /** + * 是否允许多账号在线 + * */ + private Integer maximum = 1; + + public boolean isSuperAuthOpen() { + return superAuthOpen; + } + + public void setSuperAuthOpen(boolean superAuthOpen) { + this.superAuthOpen = superAuthOpen; + } + + public String getSuperAdmin() { + return superAdmin; + } + + public void setSuperAdmin(String superAdmin) { + this.superAdmin = superAdmin; + } + + public String getRememberKey() { + return rememberKey; + } + + public void setRememberKey(String rememberKey) { + this.rememberKey = rememberKey; + } + + public String[] getOpenApi() { + return openApi; + } + + public void setOpenApi(String[] openApi) { + this.openApi = openApi; + } + + public Integer getMaximum() { + return maximum; + } + + public void setMaximum(Integer maximum) { + this.maximum = maximum; + } +} diff --git a/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/controller/MqController.java b/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/controller/MqController.java new file mode 100644 index 0000000..a0ba700 --- /dev/null +++ b/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/controller/MqController.java @@ -0,0 +1,59 @@ +package com.zhangmeng.mq.controller; + +import com.zhangmeng.model.vo.Result; +import org.springframework.amqp.core.BindingBuilder; +import org.springframework.amqp.core.FanoutExchange; +import org.springframework.amqp.core.Queue; +import org.springframework.amqp.rabbit.core.RabbitAdmin; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +@RestController +@RequestMapping("/mq") +public class MqController { + +// @Autowired +// private RabbitAdmin rabbitAdmin; +// +// private RabbitTemplate rabbitTemplate; +// +// @PostMapping("/sendMessage") +// public Result sendMessage(String queueName ,String message){ +// +// createMQIfNotExist(queueName,queueName); +// return null; +// } +// +// private void createMQIfNotExist(String queueName ,String exchangeName) { +// //判断队列是否存在 +// Properties properties = rabbitAdmin.getQueueProperties(queueName); +// if(properties == null){ +// Queue queue = new Queue(queueName, true, false, false, null); +// FanoutExchange fanoutExchange = new FanoutExchange(exchangeName); +// rabbitAdmin.declareQueue(queue); +// rabbitAdmin.declareExchange(fanoutExchange); +// rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(fanoutExchange)); +// +// String res = callAddNewListener(queueName); +// if(!StringUtils.isEmpty(res)){ +// System.out.println("-->>调用创建新的 listener feign 失败"); +// } +// +// } +// +// +// } +// +// private String callAddNewListener(String queueName){ +// return null; +// } +} diff --git a/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/service/MqService.java b/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/service/MqService.java new file mode 100644 index 0000000..196b0aa --- /dev/null +++ b/mystyle-cloud-mq/src/main/java/com/zhangmeng/mq/service/MqService.java @@ -0,0 +1,4 @@ +package com.zhangmeng.mq.service; + +public interface MqService { +} diff --git a/mystyle-cloud-mq/src/main/resources/application.yml b/mystyle-cloud-mq/src/main/resources/application.yml index 10174d9..3f0dc9f 100644 --- a/mystyle-cloud-mq/src/main/resources/application.yml +++ b/mystyle-cloud-mq/src/main/resources/application.yml @@ -3,6 +3,11 @@ server: spring: application: name: mystyle-cloud-mq + rabbitmq: + host: localhost + port: 5672 + username: guest + password: guest zipkin: sender: type: web diff --git a/mystyle-cloud-oauth/src/main/resources/application.yml b/mystyle-cloud-oauth/src/main/resources/application.yml index 93f1244..10de0c9 100644 --- a/mystyle-cloud-oauth/src/main/resources/application.yml +++ b/mystyle-cloud-oauth/src/main/resources/application.yml @@ -70,4 +70,7 @@ management: endpoint: health: show-details: ALWAYS - enabled: true \ No newline at end of file + enabled: true +logging: + file: + name: ./logs/mystyle-cloud-oauth.log \ No newline at end of file diff --git a/mystyle-cloud-quartz/pom.xml b/mystyle-cloud-quartz/pom.xml index c657f1b..730a898 100644 --- a/mystyle-cloud-quartz/pom.xml +++ b/mystyle-cloud-quartz/pom.xml @@ -10,6 +10,18 @@ 4.0.0 mystyle-cloud-quartz + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + diff --git a/mystyle-cloud-quartz/src/main/resources/application.yml b/mystyle-cloud-quartz/src/main/resources/application.yml index bce577d..7809338 100644 --- a/mystyle-cloud-quartz/src/main/resources/application.yml +++ b/mystyle-cloud-quartz/src/main/resources/application.yml @@ -80,3 +80,6 @@ management: health: show-details: ALWAYS enabled: true +logging: + file: + name: ./logs/mystyle-cloud-quartz.log diff --git a/pom.xml b/pom.xml index 2fa475f..844375c 100644 --- a/pom.xml +++ b/pom.xml @@ -279,6 +279,14 @@ spring-boot-admin-starter-client 2.5.4 + + + + de.codecentric + spring-boot-admin-server-ui + 2.5.4 + + \ No newline at end of file