Skip to content

Commit c08a364

Browse files
committed
Merge
1 parent 1656ab1 commit c08a364

File tree

228 files changed

+30816
-0
lines changed

Some content is hidden

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

228 files changed

+30816
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>io.github.microsphere-projects</groupId>
7+
<artifactId>microsphere-sentinel-parent</artifactId>
8+
<version>${revision}</version>
9+
<relativePath>../microsphere-sentinel-parent/pom.xml</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<groupId>io.github.microsphere-projects</groupId>
14+
<artifactId>microsphere-sentinel-dashboard</artifactId>
15+
<version>${revision}</version>
16+
<packaging>jar</packaging>
17+
18+
<name>Microsphere :: Alibaba Sentinel :: Dashboard</name>
19+
<description>Microsphere Alibaba Sentinel Dashboard</description>
20+
21+
<dependencies>
22+
23+
<!-- Java Common Annotations -->
24+
<dependency>
25+
<groupId>javax.annotation</groupId>
26+
<artifactId>javax.annotation-api</artifactId>
27+
</dependency>
28+
29+
<!-- Servlet API -->
30+
<dependency>
31+
<groupId>javax.servlet</groupId>
32+
<artifactId>javax.servlet-api</artifactId>
33+
</dependency>
34+
35+
<!-- Microsphere Sentinel Spring Boot Starter -->
36+
<dependency>
37+
<groupId>io.github.microsphere-projects</groupId>
38+
<artifactId>microsphere-sentinel-spring-boot-starter</artifactId>
39+
<version>${revision}</version>
40+
</dependency>
41+
42+
<!-- Microsphere Spring Boot Starter -->
43+
<dependency>
44+
<groupId>io.github.microsphere-projects</groupId>
45+
<artifactId>microsphere-core-spring-boot-starter</artifactId>
46+
<version>${revision}</version>
47+
</dependency>
48+
49+
<!-- Spring Boot -->
50+
<dependency>
51+
<groupId>org.springframework.boot</groupId>
52+
<artifactId>spring-boot-starter-web</artifactId>
53+
</dependency>
54+
55+
<dependency>
56+
<groupId>org.springframework.boot</groupId>
57+
<artifactId>spring-boot-starter-actuator</artifactId>
58+
</dependency>
59+
60+
<!-- Third-Party Dependencies -->
61+
62+
<!-- Alibaba Sentinel -->
63+
<dependency>
64+
<groupId>com.alibaba.csp</groupId>
65+
<artifactId>sentinel-core</artifactId>
66+
</dependency>
67+
68+
<!-- Alibaba Fastjson -->
69+
<dependency>
70+
<groupId>com.alibaba</groupId>
71+
<artifactId>fastjson</artifactId>
72+
</dependency>
73+
74+
<!-- Apollo -->
75+
<dependency>
76+
<groupId>com.ctrip.framework.apollo</groupId>
77+
<artifactId>apollo-openapi</artifactId>
78+
</dependency>
79+
80+
<dependency>
81+
<groupId>com.ctrip.framework.apollo</groupId>
82+
<artifactId>apollo-client</artifactId>
83+
</dependency>
84+
85+
<!-- Testing -->
86+
<dependency>
87+
<groupId>junit</groupId>
88+
<artifactId>junit</artifactId>
89+
<scope>test</scope>
90+
</dependency>
91+
92+
<dependency>
93+
<groupId>org.springframework</groupId>
94+
<artifactId>spring-test</artifactId>
95+
<scope>test</scope>
96+
</dependency>
97+
98+
<dependency>
99+
<groupId>io.github.microsphere-projects</groupId>
100+
<artifactId>microsphere-spring-test</artifactId>
101+
<version>${revision}</version>
102+
<scope>test</scope>
103+
</dependency>
104+
105+
</dependencies>
106+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
import org.springframework.boot.SpringApplication;
20+
import org.springframework.boot.autoconfigure.SpringBootApplication;
21+
import org.springframework.boot.context.event.ApplicationStartedEvent;
22+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
23+
import org.springframework.context.event.EventListener;
24+
25+
/**
26+
* Sentinel dashboard application.
27+
*
28+
* @author Carpenter Lee
29+
*/
30+
@SpringBootApplication
31+
@EnableDiscoveryClient
32+
public class DashboardApplication {
33+
34+
public static void main(String[] args) {
35+
SpringApplication.run(DashboardApplication.class, args);
36+
}
37+
38+
@EventListener(ApplicationStartedEvent.class)
39+
public void init() {
40+
InitExecutor.doInit();
41+
}
42+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 io.microsphere.sentinel.dashboard.auth;
17+
18+
import java.lang.annotation.Documented;
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Retention;
21+
import java.lang.annotation.RetentionPolicy;
22+
import java.lang.annotation.Target;
23+
24+
/**
25+
* @author lkxiaolou
26+
* @since 1.7.1
27+
*/
28+
@Retention(RetentionPolicy.RUNTIME)
29+
@Documented
30+
@Target({ElementType.METHOD})
31+
public @interface AuthAction {
32+
33+
/**
34+
* @return the privilege type
35+
*/
36+
AuthService.PrivilegeType value();
37+
38+
/**
39+
* @return the target name to control
40+
*/
41+
String targetName() default "app";
42+
43+
/**
44+
* @return the message when permission is denied
45+
*/
46+
String message() default "Permission denied";
47+
}
Lines changed: 113 additions & 0 deletions
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 io.microsphere.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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 io.microsphere.sentinel.dashboard.auth;
17+
18+
import org.springframework.web.servlet.HandlerInterceptor;
19+
20+
/**
21+
* The web interceptor for privilege-based authorization.
22+
*
23+
* @author lkxiaolou
24+
* @author wxq
25+
* @since 1.7.1
26+
*/
27+
public interface AuthorizationInterceptor extends HandlerInterceptor {
28+
29+
}

0 commit comments

Comments
 (0)