Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support console management #4115

Merged
merged 27 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
feeb02c
feature: add console-fe
jameslcj Jan 10, 2020
b5b7c7c
update: update Copyright
jameslcj Jan 10, 2020
ea77508
feature: add index.html
jameslcj Jan 10, 2020
38b7cf3
feature: update package.json
jameslcj Jan 10, 2020
48f39f0
Merge branch 'develop' of https://github.com/seata/seata into develop
jameslcj Jan 10, 2020
7228332
Merge branch 'develop' of https://github.com/seata/seata into develop
jameslcj Jan 13, 2020
2c52916
feature: add console
jameslcj Jan 13, 2020
0f1ba6d
fix servlet-api conflicts
slievrly Jan 13, 2020
1dcc91c
feature: add .gitattributes
jameslcj Jan 13, 2020
199ccf6
Merge branch 'develop' of https://github.com/seata/seata into develop
jameslcj Feb 27, 2020
8394a4f
feature: add seata console management #2173
jameslcj Feb 28, 2020
591ee0f
feature: add seata console management #2173
jameslcj Feb 28, 2020
f4c04a9
feature: add seata console management #2173
jameslcj Feb 28, 2020
3578170
feature: add security configuration and open api #2173
jameslcj Feb 28, 2020
8550ce5
Merge branch 'develop' of https://github.com/seata/seata into develop
jameslcj Feb 28, 2020
8bdaa32
feature: ignore resources validate #2173
jameslcj Feb 28, 2020
e21d401
Merge branch 'develop' into develop
zjinlei Feb 28, 2020
4ea6039
Merge branch 'develop' into develop
zjinlei Mar 5, 2020
a7dc68e
Merge branch 'develop' into develop
zjinlei Mar 6, 2020
33489eb
resolve conflicts
slievrly Sep 16, 2021
a004787
init console
slievrly Sep 16, 2021
82bc0da
init console
slievrly Sep 16, 2021
e76ef2d
fix checkstyle and javadoc
slievrly Sep 16, 2021
92ae6f1
add change log and author
slievrly Sep 16, 2021
29797de
Merge branch 'develop' into PR_Console
xingfudeshi Sep 17, 2021
7441501
Merge branch 'develop' into PR_Console
slievrly Nov 4, 2021
0dbc9a8
Merge branch 'develop' into pr_console
slievrly Nov 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.js linguist-language=java
*.css linguist-language=java
*.html linguist-language=java
3 changes: 3 additions & 0 deletions changes/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单


### feature:
- [[#4042](https://github.com/seata/seata/pull/4042)] 支持用户控制台
- [[#3472](https://github.com/seata/seata/pull/3472)] 添加redisLocker的lua模式
- [[#3575](https://github.com/seata/seata/pull/3575)] 支持对锁和会话不同存储的混合使用
- [[#3374](https://github.com/seata/seata/pull/3374)] 支持mysql INSERT ON DUPLICATE KEY UPDATE
Expand Down Expand Up @@ -162,6 +163,8 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [Rubbernecker](https://github.com/Rubbernecker)
- [dmego](https://github.com/dmego)
- [zhixing](https://github.com/chenlei3641)
- [jameslcj](https://github.com/jameslcj)
- [wfnuser](https://github.com/wfnuser)
- [siyu](https://github.com/Pinocchio2018)
- [xujj](https://github.com/XBNGit)

Expand Down
3 changes: 3 additions & 0 deletions changes/en-us/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@


### feature:
- [[#4042](https://github.com/seata/seata/pull/4042)] support console management
- [[#3472](https://github.com/seata/seata/pull/3472)] add redisLocker's lua mode
- [[#3575](https://github.com/seata/seata/pull/3575)] support the mixed use of different storages of locks and sessions
- [[#3374](https://github.com/seata/seata/pull/3374)] add a Executor for INSERT ON DUPLICATE KEY UPDATE
Expand Down Expand Up @@ -160,6 +161,8 @@
- [elrond-g](https://github.com/elrond-g)
- [dmego](https://github.com/dmego)
- [zhixing](https://github.com/chenlei3641)
- [jameslcj](https://github.com/jameslcj)
- [wfnuser](https://github.com/wfnuser)
- [siyu](https://github.com/Pinocchio2018)
- [xujj](https://github.com/XBNGit)

Expand Down
82 changes: 82 additions & 0 deletions console/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?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">
<parent>
<groupId>io.seata</groupId>
<artifactId>seata-parent</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>seata-console</artifactId>
<packaging>jar</packaging>
<name>seata-console ${project.version}</name>

<properties>
<spring-boot.version>2.3.10.RELEASE</spring-boot.version>
<jwt.version>0.10.5</jwt.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>io.jsonwebtoken</groupId>-->
<!--<artifactId>jjwt</artifactId>-->
<!--<version>${jwt.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>${jwt.version}</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>${jwt.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>${jwt.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
37 changes: 37 additions & 0 deletions console/src/main/java/io/seata/console/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.console;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* The type Application.
*
* @author jameslcj
*/
@SpringBootApplication(scanBasePackages = {"io.seata.console"})
public class Application {

/**
* The entry point of application.
*
* @param args the input arguments
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
124 changes: 124 additions & 0 deletions console/src/main/java/io/seata/console/config/WebSecurityConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.console.config;

import io.seata.console.filter.JwtAuthenticationTokenFilter;
import io.seata.console.security.CustomUserDetailsServiceImpl;
import io.seata.console.security.JwtAuthenticationEntryPoint;
import io.seata.console.utils.JwtTokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.BeanIds;
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.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
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;

/**
* Spring security config
*
* @author jameslcj
*/
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

/**
* The constant AUTHORIZATION_HEADER.
*/
public static final String AUTHORIZATION_HEADER = "Authorization";

/**
* The constant AUTHORIZATION_TOKEN.
*/
public static final String AUTHORIZATION_TOKEN = "access_token";

/**
* The constant SECURITY_IGNORE_URLS_SPILT_CHAR.
*/
public static final String SECURITY_IGNORE_URLS_SPILT_CHAR = ",";

/**
* The constant TOKEN_PREFIX.
*/
public static final String TOKEN_PREFIX = "Bearer ";

@Autowired
private CustomUserDetailsServiceImpl userDetailsService;

@Autowired
private JwtAuthenticationEntryPoint unauthorizedHandler;

@Autowired
private JwtTokenUtils tokenProvider;

@Autowired
private Environment env;

@Bean(name = BeanIds.AUTHENTICATION_MANAGER)
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
}

@Override
public void configure(WebSecurity web) {
String ignoreURLs = env.getProperty("seata.security.ignore.urls", "/**");
for (String ignoreURL : ignoreURLs.trim().split(SECURITY_IGNORE_URLS_SPILT_CHAR)) {
web.ignoring().antMatchers(ignoreURL.trim());
}
}

@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().authenticated().and()
// custom token authorize exception handler
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
// since we use jwt, session is not necessary
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
// since we use jwt, csrf is not necessary
.csrf().disable();
http.addFilterBefore(new JwtAuthenticationTokenFilter(tokenProvider),
UsernamePasswordAuthenticationFilter.class);

// disable cache
http.headers().cacheControl();
}

/**
* Password encoder password encoder.
*
* @return the password encoder
*/
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}

}
104 changes: 104 additions & 0 deletions console/src/main/java/io/seata/console/constant/Code.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.console.constant;

/**
* The Code for the response of message
*
* @author jameslcj
*/
public enum Code {
/**
* response success
*/
SUCCESS(200, "ok"),
/**
* server error
*/
ERROR(500, "Server error"),
/**
* the custom error
*/
LOGIN_FAILED(401, "Login failed");

/**
* The Code.
*/
public int code;

/**
* The Msg.
*/
public String msg;

private Code(int code, String msg) {
this.code = code;
this.msg = msg;
}

/**
* Gets code.
*
* @return the code
*/
public int getCode() {
return this.code;
}

/**
* Sets code.
*
* @param code the code
*/
public void setCode(int code) {
this.code = code;
}

/**
* Gets msg.
*
* @return the msg
*/
public String getMsg() {
return msg;
}

/**
* Sets msg.
*
* @param msg the msg
*/
public void setMsg(String msg) {
this.msg = msg;
}

/**
* Gets error msg.
*
* @param code the code
* @return the error msg
*/
public static String getErrorMsg(int code) {
Code[] errorCodes = values();
for (Code errCode : errorCodes) {
if (errCode.getCode() == code) {
return errCode.getMsg();
}
}
return null;
}
}

Loading