添加日志 2021年11月17日15:50:29

master
zhangmeng 2021-11-17 15:50:43 +08:00
parent c6ae35354d
commit 33be0d7c00
18 changed files with 322 additions and 9 deletions

View File

@ -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
enabled: true
info:
version: 1.0
name: mystyle-cloud-admin-manager
author: zhangmeng
blog: 47.104.229.92:3000

View File

@ -77,5 +77,12 @@
<version>2.2.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server-ui -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -66,4 +66,8 @@ management:
endpoint:
health:
show-details: ALWAYS
enabled: true
enabled: true
logging:
file:
name: ./logs/mystyle-cloud-blog.log
level: debug

View File

@ -23,4 +23,7 @@ canal:
host: 127.0.0.1
port: 11111
userName: canal
password: canal
password: canal
logging:
file:
name: ./logs/mystyle-cloud-canal.log

View File

@ -68,4 +68,7 @@ management:
endpoint:
health:
show-details: ALWAYS
enabled: true
enabled: true
logging:
file:
name: ./logs/mystyle-cloud-fiction.log

View File

@ -77,4 +77,7 @@ management:
endpoint:
health:
show-details: ALWAYS
enabled: true
enabled: true
logging:
file:
name: ./logs/mystyle-cloud-file.log

View File

@ -93,3 +93,6 @@ management:
health:
show-details: ALWAYS
enabled: true
logging:
file:
name: ./logs/mystyle-cloud-gateway.log

View File

@ -72,4 +72,7 @@ management:
endpoint:
health:
show-details: ALWAYS
enabled: true
enabled: true
logging:
file:
name: ./logs/mystyle-cloud-mail.log

View File

@ -10,12 +10,25 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>mystyle-cloud-mq</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>com.zhangmeng</groupId>
<artifactId>mystyle-cloud-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>

View File

@ -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 202191416: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
* Httphttp
* @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(); // 其他地址需要认证授权
}
}

View File

@ -0,0 +1,79 @@
package com.zhangmeng.mq.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author
* @date 202191416: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;
}
}

View File

@ -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;
// }
}

View File

@ -0,0 +1,4 @@
package com.zhangmeng.mq.service;
public interface MqService {
}

View File

@ -3,6 +3,11 @@ server:
spring:
application:
name: mystyle-cloud-mq
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
zipkin:
sender:
type: web

View File

@ -70,4 +70,7 @@ management:
endpoint:
health:
show-details: ALWAYS
enabled: true
enabled: true
logging:
file:
name: ./logs/mystyle-cloud-oauth.log

View File

@ -10,6 +10,18 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>mystyle-cloud-quartz</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>

View File

@ -80,3 +80,6 @@ management:
health:
show-details: ALWAYS
enabled: true
logging:
file:
name: ./logs/mystyle-cloud-quartz.log

View File

@ -279,6 +279,14 @@
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.5.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/de.codecentric/spring-boot-admin-server-ui -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.5.4</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>