Skip to content

Commit b5fbfaa

Browse files
committed
Spring Cloud Alibaba基础教程:Sentinel Dashboard中修改规则同步到Nacos
1 parent 5d62b32 commit b5fbfaa

File tree

206 files changed

+22704
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+22704
-1
lines changed

4-Finchley/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
- [Spring Cloud Alibaba基础教程:使用Sentinel实现接口限流](http://blog.didispace.com/spring-cloud-alibaba-sentinel-1/)
5050
- [Spring Cloud Alibaba基础教程:Sentinel使用Nacos存储规则](http://blog.didispace.com/spring-cloud-alibaba-sentinel-2-1/)
5151
- [Spring Cloud Alibaba基础教程:Sentinel使用Apollo存储规则](http://blog.didispace.com/spring-cloud-alibaba-sentinel-2-2/)
52-
- [Spring Cloud Alibaba基础教程:Sentinel Dashboard同步Apollo存储规则](http://blog.didispace.com/spring-cloud-alibaba-sentinel-2-3/)
52+
- [Spring Cloud Alibaba基础教程:Sentinel Dashboard中修改规则同步到Apollo](http://blog.didispace.com/spring-cloud-alibaba-sentinel-2-3/)
53+
- [Spring Cloud Alibaba基础教程:Sentinel Dashboard中修改规则同步到Nacos](http://blog.didispace.com/spring-cloud-alibaba-sentinel-2-4/)
54+
5355

5456
##### Spring Cloud Stream专题补充
5557

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>com.alibaba.csp</groupId>
8+
<artifactId>sentinel-parent</artifactId>
9+
<version>1.6.0</version>
10+
</parent>
11+
12+
<artifactId>alibaba-sentinel-dashboard-nacos</artifactId>
13+
<packaging>jar</packaging>
14+
15+
<properties>
16+
<maven.compiler.source>1.8</maven.compiler.source>
17+
<maven.compiler.target>1.8</maven.compiler.target>
18+
<spring.boot.version>2.0.5.RELEASE</spring.boot.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.alibaba.csp</groupId>
24+
<artifactId>sentinel-core</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>com.alibaba.csp</groupId>
28+
<artifactId>sentinel-web-servlet</artifactId>
29+
<version>${project.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>com.alibaba.csp</groupId>
33+
<artifactId>sentinel-transport-simple-http</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>com.alibaba.csp</groupId>
37+
<artifactId>sentinel-parameter-flow-control</artifactId>
38+
<version>${project.version}</version>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>org.springframework.boot</groupId>
43+
<artifactId>spring-boot-starter-web</artifactId>
44+
<version>${spring.boot.version}</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.springframework.boot</groupId>
48+
<artifactId>spring-boot-starter-logging</artifactId>
49+
<version>${spring.boot.version}</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-starter-test</artifactId>
54+
<version>${spring.boot.version}</version>
55+
<scope>test</scope>
56+
</dependency>
57+
58+
<dependency>
59+
<groupId>log4j</groupId>
60+
<artifactId>log4j</artifactId>
61+
<version>1.2.14</version>
62+
</dependency>
63+
64+
<dependency>
65+
<groupId>commons-lang</groupId>
66+
<artifactId>commons-lang</artifactId>
67+
<version>2.6</version>
68+
</dependency>
69+
70+
<dependency>
71+
<groupId>org.apache.httpcomponents</groupId>
72+
<artifactId>httpclient</artifactId>
73+
<version>4.5.3</version>
74+
</dependency>
75+
<dependency>
76+
<groupId>org.apache.httpcomponents</groupId>
77+
<artifactId>httpcore</artifactId>
78+
<version>4.4.5</version>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.apache.httpcomponents</groupId>
82+
<artifactId>httpasyncclient</artifactId>
83+
<version>4.1.3</version>
84+
</dependency>
85+
<dependency>
86+
<groupId>org.apache.httpcomponents</groupId>
87+
<artifactId>httpcore-nio</artifactId>
88+
<version>4.4.6</version>
89+
</dependency>
90+
<dependency>
91+
<groupId>com.alibaba</groupId>
92+
<artifactId>fastjson</artifactId>
93+
</dependency>
94+
95+
<!-- for Nacos rule publisher sample -->
96+
<dependency>
97+
<groupId>com.alibaba.csp</groupId>
98+
<artifactId>sentinel-datasource-nacos</artifactId>
99+
<!--<scope>test</scope>-->
100+
</dependency>
101+
102+
<dependency>
103+
<groupId>com.ctrip.framework.apollo</groupId>
104+
<artifactId>apollo-openapi</artifactId>
105+
<version>1.2.0</version>
106+
<scope>test</scope>
107+
</dependency>
108+
109+
<dependency>
110+
<groupId>junit</groupId>
111+
<artifactId>junit</artifactId>
112+
<scope>test</scope>
113+
</dependency>
114+
<dependency>
115+
<groupId>org.mockito</groupId>
116+
<artifactId>mockito-core</artifactId>
117+
<scope>test</scope>
118+
</dependency>
119+
<dependency>
120+
<groupId>com.github.stefanbirkner</groupId>
121+
<artifactId>system-rules</artifactId>
122+
<version>1.16.1</version>
123+
<scope>test</scope>
124+
</dependency>
125+
</dependencies>
126+
127+
<build>
128+
<finalName>sentinel-dashboard</finalName>
129+
<plugins>
130+
<plugin>
131+
<groupId>org.springframework.boot</groupId>
132+
<artifactId>spring-boot-maven-plugin</artifactId>
133+
<configuration>
134+
<fork>true</fork>
135+
<mainClass>com.alibaba.csp.sentinel.dashboard.DashboardApplication</mainClass>
136+
</configuration>
137+
<executions>
138+
<execution>
139+
<goals>
140+
<goal>repackage</goal>
141+
</goals>
142+
</execution>
143+
</executions>
144+
</plugin>
145+
146+
<plugin>
147+
<groupId>org.apache.maven.plugins</groupId>
148+
<artifactId>maven-compiler-plugin</artifactId>
149+
<configuration>
150+
<source>${maven.compiler.source}</source>
151+
<target>${maven.compiler.target}</target>
152+
</configuration>
153+
</plugin>
154+
155+
<plugin>
156+
<groupId>org.apache.maven.plugins</groupId>
157+
<artifactId>maven-deploy-plugin</artifactId>
158+
<version>${maven.deploy.version}</version>
159+
<configuration>
160+
<skip>true</skip>
161+
</configuration>
162+
</plugin>
163+
</plugins>
164+
165+
<resources>
166+
<resource>
167+
<directory>src/main/resources</directory>
168+
</resource>
169+
170+
<resource>
171+
<directory>src/main/webapp/</directory>
172+
<excludes>
173+
<exclude>resources/node_modules/**</exclude>
174+
</excludes>
175+
</resource>
176+
</resources>
177+
</build>
178+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 1999-2018 Alibaba Group Holding Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.alibaba.csp.sentinel.dashboard;
17+
18+
import com.alibaba.csp.sentinel.init.InitExecutor;
19+
20+
import org.springframework.boot.SpringApplication;
21+
import org.springframework.boot.autoconfigure.SpringBootApplication;
22+
23+
/**
24+
* Sentinel dashboard application.
25+
*
26+
* @author Carpenter Lee
27+
*/
28+
@SpringBootApplication
29+
public class DashboardApplication {
30+
31+
public static void main(String[] args) {
32+
triggerSentinelInit();
33+
SpringApplication.run(DashboardApplication.class, args);
34+
}
35+
36+
private static void triggerSentinelInit() {
37+
new Thread(() -> InitExecutor.doInit()).start();
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Copyright 1999-2018 Alibaba Group Holding Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.alibaba.csp.sentinel.dashboard.auth;
17+
18+
/**
19+
* Interface for authentication and authorization.
20+
*
21+
* @author Carpenter Lee
22+
* @since 1.5.0
23+
*/
24+
public interface AuthService<R> {
25+
26+
/**
27+
* Get the authentication user.
28+
*
29+
* @param request the request contains the user information
30+
* @return the auth user represent the current user, when the user is illegal, a null value will return.
31+
*/
32+
AuthUser getAuthUser(R request);
33+
34+
/**
35+
* Privilege type.
36+
*/
37+
enum PrivilegeType {
38+
/**
39+
* Read rule
40+
*/
41+
READ_RULE,
42+
/**
43+
* Create or modify rule
44+
*/
45+
WRITE_RULE,
46+
/**
47+
* Delete rule
48+
*/
49+
DELETE_RULE,
50+
/**
51+
* Read metrics
52+
*/
53+
READ_METRIC,
54+
/**
55+
* Add machine
56+
*/
57+
ADD_MACHINE,
58+
/**
59+
* All privileges above are granted.
60+
*/
61+
ALL
62+
}
63+
64+
/**
65+
* Represents the current user.
66+
*/
67+
interface AuthUser {
68+
69+
/**
70+
* Query whether current user has the specific privilege to the target, the target
71+
* may be an app name or an ip address, or other destination.
72+
* <p>
73+
* This method will use return value to represent whether user has the specific
74+
* privileges to the target, but to throw a RuntimeException to represent no auth
75+
* is also a good way.
76+
* </p>
77+
*
78+
* @param target the target to check
79+
* @param privilegeType the privilege type to check
80+
* @return if current user has the specific privileges to the target, return true,
81+
* otherwise return false.
82+
*/
83+
boolean authTarget(String target, PrivilegeType privilegeType);
84+
85+
/**
86+
* Check whether current user is a super-user.
87+
*
88+
* @return if current user is super user return true, else return false.
89+
*/
90+
boolean isSuperUser();
91+
92+
/**
93+
* Get current user's nick name.
94+
*
95+
* @return current user's nick name.
96+
*/
97+
String getNickName();
98+
99+
/**
100+
* Get current user's login name.
101+
*
102+
* @return current user's login name.
103+
*/
104+
String getLoginName();
105+
106+
/**
107+
* Get current user's ID.
108+
*
109+
* @return ID of current user
110+
*/
111+
String getId();
112+
}
113+
}

0 commit comments

Comments
 (0)