Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzlite
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzlite
提交
919c8a3f
提交
919c8a3f
编写于
9月 15, 2020
作者:
ibizdev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
zhouweidong 发布系统代码
上级
ec3119d5
变更
15
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
447 行增加
和
1 行删除
+447
-1
pom.xml
ibzlite-boot/pom.xml
+5
-0
application.yml
ibzlite-boot/src/main/resources/application.yml
+1
-1
pom.xml
ibzlite-provider/ibzlite-provider-api/pom.xml
+62
-0
Dockerfile
...-provider/ibzlite-provider-api/src/main/docker/Dockerfile
+17
-0
ibzlite-provider-api.yaml
...te-provider-api/src/main/docker/ibzlite-provider-api.yaml
+32
-0
apiAutoConfiguration.java
...main/java/cn/ibizlab/api/config/apiAutoConfiguration.java
+56
-0
apiRestConfiguration.java
...main/java/cn/ibizlab/api/config/apiRestConfiguration.java
+8
-0
apiSecurityConfig.java
...rc/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
+139
-0
apiServiceProperties.java
...main/java/cn/ibizlab/api/config/apiServiceProperties.java
+15
-0
ibzliteapiApplication.java
...i/src/main/java/cn/ibizlab/api/ibzliteapiApplication.java
+57
-0
application-api-dev.yml
...e-provider-api/src/main/resources/application-api-dev.yml
+2
-0
application-api-prod.yml
...-provider-api/src/main/resources/application-api-prod.yml
+6
-0
application.yml
...r/ibzlite-provider-api/src/main/resources/application.yml
+5
-0
logback-spring.xml
...bzlite-provider-api/src/main/resources/logback-spring.xml
+41
-0
pom.xml
ibzlite-provider/pom.xml
+1
-0
未找到文件。
ibzlite-boot/pom.xml
浏览文件 @
919c8a3f
...
...
@@ -19,6 +19,11 @@
<artifactId>
ibzlite-core
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
cn.ibizlab
</groupId>
<artifactId>
ibzlite-provider-api
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
cn.ibizlab
</groupId>
<artifactId>
ibzlite-app-web
</artifactId>
...
...
ibzlite-boot/src/main/resources/application.yml
浏览文件 @
919c8a3f
spring
:
profiles
:
include
:
sys ,nacos, web-dev, dev
include
:
sys ,nacos, web-dev,
api-dev,
dev
application
:
name
:
ibzlite
main
:
...
...
ibzlite-provider/ibzlite-provider-api/pom.xml
0 → 100644
浏览文件 @
919c8a3f
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<artifactId>
ibzlite-provider
</artifactId>
<groupId>
cn.ibizlab
</groupId>
<version>
1.0.0.0
</version>
</parent>
<artifactId>
ibzlite-provider-api
</artifactId>
<name>
Ibzlite Microservice api
</name>
<description>
micorservice
</description>
<dependencies>
<dependency>
<groupId>
cn.ibizlab
</groupId>
<artifactId>
ibzlite-core
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>
api
</id>
<build>
<resources>
<resource>
<directory>
${basedir}/src/main/resources
</directory>
<includes>
<include>
**/**
</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<finalName>
ibzlite-provider-api
</finalName>
<jvmArguments>
-Dfile.encoding=UTF-8
</jvmArguments>
<mainClass>
cn.ibizlab.api.ibzliteapiApplication
</mainClass>
<outputDirectory>
../../
</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
ibzlite-provider/ibzlite-provider-api/src/main/docker/Dockerfile
0 → 100644
浏览文件 @
919c8a3f
FROM
openjdk:8-jre-alpine
ENV
TZ=Asia/Shanghai \
SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
IBIZ_SLEEP=0 \
JAVA_OPTS=""
RUN
ln
-snf
/usr/share/zoneinfo/
$TZ
/etc/localtime
&&
echo
$TZ
>
/etc/timezone
CMD
echo "The application will start in ${IBIZ_SLEEP}s..." && \
sleep ${IBIZ_SLEEP} && \
java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /ibzlite-provider-api.jar
EXPOSE
8081
ADD
ibzlite-provider-api.jar /ibzlite-provider-api.jar
ibzlite-provider/ibzlite-provider-api/src/main/docker/ibzlite-provider-api.yaml
0 → 100644
浏览文件 @
919c8a3f
version
:
"
3.2"
services
:
ibzlite-provider-api
:
image
:
registry.cn-shanghai.aliyuncs.com/ibizsys/ibzlite-provider-api:latest
ports
:
-
"
8081:8081"
networks
:
-
agent_network
deploy
:
resources
:
limits
:
memory
:
4048M
reservations
:
memory
:
400M
mode
:
replicated
replicas
:
1
volumes
:
-
"
nfs:/app/file"
volumes
:
nfs
:
driver
:
local
driver_opts
:
type
:
"
nfs"
o
:
"
addr=172.16.240.109,rw"
device
:
"
:/nfs"
networks
:
agent_network
:
driver
:
overlay
attachable
:
true
ibzlite-provider/ibzlite-provider-api/src/main/java/cn/ibizlab/api/config/apiAutoConfiguration.java
0 → 100644
浏览文件 @
919c8a3f
package
cn
.
ibizlab
.
api
.
config
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.web.servlet.ServletRegistrationBean
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
;
import
org.springframework.web.servlet.DispatcherServlet
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
org.springframework.context.annotation.Import
;
@Configuration
@ConditionalOnClass
(
apiRestConfiguration
.
class
)
@ConditionalOnWebApplication
@EnableConfigurationProperties
(
apiServiceProperties
.
class
)
public
class
apiAutoConfiguration
implements
ApplicationContextAware
{
protected
ApplicationContext
applicationContext
;
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
{
this
.
applicationContext
=
applicationContext
;
}
@Bean
(
"asyncExecutor"
)
public
Executor
asyncExecutor
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setCorePoolSize
(
10
);
executor
.
setMaxPoolSize
(
20
);
executor
.
setQueueCapacity
(
2000
);
executor
.
setKeepAliveSeconds
(
600
);
executor
.
setThreadNamePrefix
(
"asyncExecutor-"
);
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
return
executor
;
}
// @Bean
// public ServletRegistrationBean apiServlet() {
// AnnotationConfigWebApplicationContext dispatcherServletConfiguration = new AnnotationConfigWebApplicationContext();
// dispatcherServletConfiguration.setParent(applicationContext);
// dispatcherServletConfiguration.register(apiRestConfiguration.class);
// DispatcherServlet servlet = new DispatcherServlet(dispatcherServletConfiguration);
// String path = "/api";
// String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
// ServletRegistrationBean registrationBean = new ServletRegistrationBean(servlet, urlMapping);
// registrationBean.setName("api");
// return registrationBean;
// }
}
ibzlite-provider/ibzlite-provider-api/src/main/java/cn/ibizlab/api/config/apiRestConfiguration.java
0 → 100644
浏览文件 @
919c8a3f
package
cn
.
ibizlab
.
api
.
config
;
import
org.springframework.context.annotation.ComponentScan
;
@ComponentScan
(
"cn.ibizlab.api"
)
public
class
apiRestConfiguration
{
}
ibzlite-provider/ibzlite-provider-api/src/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
0 → 100644
浏览文件 @
919c8a3f
package
cn
.
ibizlab
.
api
.
config
;
import
cn.ibizlab.util.security.AuthenticationEntryPoint
;
import
cn.ibizlab.util.security.AuthorizationTokenFilter
;
import
cn.ibizlab.util.service.AuthenticationUserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.config.core.GrantedAuthorityDefaults
;
import
org.springframework.security.config.http.SessionCreationPolicy
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.beans.factory.annotation.Qualifier
;
@Profile
(
"api-prod"
)
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
public
class
apiSecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Autowired
private
AuthenticationEntryPoint
unauthorizedHandler
;
@Autowired
private
AuthenticationUserService
userDetailsService
;
/**
* 自定义基于JWT的安全过滤器
*/
@Autowired
AuthorizationTokenFilter
authenticationTokenFilter
;
@Value
(
"${ibiz.auth.path:v7/login}"
)
private
String
loginPath
;
@Value
(
"${ibiz.auth.logoutpath:v7/logout}"
)
private
String
logoutPath
;
@Value
(
"${ibiz.file.uploadpath:ibizutil/upload}"
)
private
String
uploadpath
;
@Value
(
"${ibiz.file.downloadpath:ibizutil/download}"
)
private
String
downloadpath
;
@Value
(
"${ibiz.file.previewpath:ibizutil/preview}"
)
private
String
previewpath
;
@Value
(
"${ibiz.auth.excludesPattern:}"
)
private
String
[]
excludesPattern
;
@Autowired
public
void
configureGlobal
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
userDetailsService
(
userDetailsService
)
.
passwordEncoder
(
passwordEncoderBean
());
}
@Bean
GrantedAuthorityDefaults
grantedAuthorityDefaults
()
{
// Remove the ROLE_ prefix
return
new
GrantedAuthorityDefaults
(
""
);
}
@Bean
public
PasswordEncoder
passwordEncoderBean
()
{
return
new
BCryptPasswordEncoder
();
}
@Bean
@Override
public
AuthenticationManager
authenticationManagerBean
()
throws
Exception
{
return
super
.
authenticationManagerBean
();
}
@Override
protected
void
configure
(
HttpSecurity
httpSecurity
)
throws
Exception
{
httpSecurity
// 禁用 CSRF
.
csrf
().
disable
()
// 授权异常
.
exceptionHandling
().
authenticationEntryPoint
(
unauthorizedHandler
).
and
()
// 不创建会话
.
sessionManagement
().
sessionCreationPolicy
(
SessionCreationPolicy
.
STATELESS
).
and
()
// 过滤请求
.
authorizeRequests
()
.
antMatchers
(
HttpMethod
.
GET
,
"/*.html"
,
"/**/*.html"
,
"/**/*.css"
,
"/**/*.js"
,
"/**/*.ico"
,
"/**/assets/**"
,
"/**/css/**"
,
"/**/fonts/**"
,
"/**/js/**"
,
"/**/img/**"
,
"/"
,
"webjars/**"
,
"/swagger-resources/**"
,
"/v2/**"
).
permitAll
()
//放行登录请求
.
antMatchers
(
HttpMethod
.
POST
,
"/"
+
loginPath
).
permitAll
()
//放行注销请求
.
antMatchers
(
HttpMethod
.
GET
,
"/"
+
logoutPath
).
permitAll
()
// 文件操作
.
antMatchers
(
"/"
+
downloadpath
+
"/**"
).
permitAll
()
.
antMatchers
(
"/"
+
uploadpath
).
permitAll
()
.
antMatchers
(
"/"
+
previewpath
+
"/**"
).
permitAll
();
for
(
String
excludePattern
:
excludesPattern
)
{
authenticationTokenFilter
.
addExcludePattern
(
excludePattern
);
httpSecurity
.
authorizeRequests
().
antMatchers
(
excludePattern
).
permitAll
();
}
// 所有请求都需要认证
httpSecurity
.
authorizeRequests
().
anyRequest
().
authenticated
()
// 防止iframe 造成跨域
.
and
().
headers
().
frameOptions
().
disable
();
httpSecurity
.
addFilterBefore
(
authenticationTokenFilter
,
UsernamePasswordAuthenticationFilter
.
class
);
}
}
ibzlite-provider/ibzlite-provider-api/src/main/java/cn/ibizlab/api/config/apiServiceProperties.java
0 → 100644
浏览文件 @
919c8a3f
package
cn
.
ibizlab
.
api
.
config
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
lombok.Data
;
@ConfigurationProperties
(
prefix
=
"service.api"
)
@Data
public
class
apiServiceProperties
{
private
boolean
enabled
;
private
boolean
auth
;
}
\ No newline at end of file
ibzlite-provider/ibzlite-provider-api/src/main/java/cn/ibizlab/api/ibzliteapiApplication.java
0 → 100644
浏览文件 @
919c8a3f
package
cn
.
ibizlab
.
api
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.data.mongodb.repository.config.EnableMongoRepositories
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
cn.ibizlab.util.web.SearchContextHandlerMethodArgumentResolver
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.List
;
@Slf4j
@EnableDiscoveryClient
@Configuration
@EnableTransactionManagement
@ComponentScan
(
basePackages
=
{
"cn.ibizlab"
}
// ,excludeFilters={
// @ComponentScan.Filter(type= org.springframework.context.annotation.FilterType.REGEX,pattern="cn.ibizlab.api.rest.xxx"),
// }
)
@EnableMongoRepositories
(
basePackages
=
{
"cn.ibizlab"
})
@MapperScan
(
"cn.ibizlab.*.mapper"
)
@SpringBootApplication
(
exclude
=
{
org
.
springframework
.
boot
.
autoconfigure
.
security
.
servlet
.
SecurityAutoConfiguration
.
class
,
org
.
springframework
.
boot
.
autoconfigure
.
mongo
.
MongoAutoConfiguration
.
class
,
})
@Import
({
org
.
springframework
.
cloud
.
openfeign
.
FeignClientsConfiguration
.
class
})
@EnableFeignClients
(
basePackages
=
{
"cn.ibizlab"
})
@EnableAsync
@EnableScheduling
public
class
ibzliteapiApplication
extends
WebMvcConfigurerAdapter
{
@Autowired
SearchContextHandlerMethodArgumentResolver
resolver
;
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ibzliteapiApplication
.
class
,
args
);
}
@Override
public
void
addArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
argumentResolvers
)
{
super
.
addArgumentResolvers
(
argumentResolvers
);
argumentResolvers
.
add
(
resolver
);
}
}
ibzlite-provider/ibzlite-provider-api/src/main/resources/application-api-dev.yml
0 → 100644
浏览文件 @
919c8a3f
server
:
port
:
8081
\ No newline at end of file
ibzlite-provider/ibzlite-provider-api/src/main/resources/application-api-prod.yml
0 → 100644
浏览文件 @
919c8a3f
server
:
port
:
8081
#Log配置
logging
:
level
:
cn.ibizlab
:
info
\ No newline at end of file
ibzlite-provider/ibzlite-provider-api/src/main/resources/application.yml
0 → 100644
浏览文件 @
919c8a3f
spring
:
profiles
:
include
:
sys ,nacos, api-prod
application
:
name
:
ibzlite-api
\ No newline at end of file
ibzlite-provider/ibzlite-provider-api/src/main/resources/logback-spring.xml
0 → 100644
浏览文件 @
919c8a3f
<?xml version="1.0" encoding="UTF-8"?>
<configuration
debug=
"false"
>
<property
name=
"LOG_PATH"
value=
"logs"
/>
<property
name=
"LOG_PATTERN"
value=
"%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %-40.40logger{39} : %msg%n"
/>
<!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 -->
<conversionRule
conversionWord=
"clr"
converterClass=
"org.springframework.boot.logging.logback.ColorConverter"
/>
<conversionRule
conversionWord=
"wex"
converterClass=
"org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"
/>
<conversionRule
conversionWord=
"wEx"
converterClass=
"org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"
/>
<!-- 彩色日志格式 -->
<property
name=
"LOG_PATTERN2"
value=
"${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr([${LOG_LEVEL_PATTERN:-%5p}]) %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"
/>
<!-- 控制台输出 -->
<appender
name=
"Console"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
${LOG_PATTERN}
</pattern>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender
name=
"file"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<!--日志文件输出的文件名-->
<FileNamePattern>
${LOG_PATH}/ibzlite-api.%d{yyyy-MM-dd}.log
</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>
30
</MaxHistory>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
${LOG_PATTERN}
</pattern>
</encoder>
<!--日志文件最大的大小-->
<triggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"
>
<MaxFileSize>
100MB
</MaxFileSize>
</triggeringPolicy>
</appender>
<!-- 日志输出级别 -->
<root
level=
"INFO"
>
<appender-ref
ref=
"Console"
/>
<appender-ref
ref=
"file"
/>
</root>
</configuration>
ibzlite-provider/pom.xml
浏览文件 @
919c8a3f
...
...
@@ -15,6 +15,7 @@
<description>
Ibzlite Provider
</description>
<modules>
<module>
ibzlite-provider-api
</module>
</modules>
<dependencies>
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录