Bladeren bron

dashboard: code rearrangement and javadoc refinement

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 5 jaren geleden
bovenliggende
commit
16d92b8821
10 gewijzigde bestanden met toevoegingen van 48 en 44 verwijderingen
  1. +20
    -18
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthService.java
  2. +4
    -3
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/FakeAuthServiceImpl.java
  3. +3
    -3
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java
  4. +3
    -2
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java
  5. +3
    -3
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthorityRuleController.java
  6. +3
    -3
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DegradeController.java
  7. +3
    -3
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/FlowControllerV1.java
  8. +3
    -3
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java
  9. +3
    -3
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java
  10. +3
    -3
      sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java

sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/AuthService.java → sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthService.java Bestand weergeven

@@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.dashboard.service;
package com.alibaba.csp.sentinel.dashboard.auth;

/**
* Interface about authentication and authorization
* Interface for authentication and authorization.
*
* @author Carpenter Lee
* @since 1.5.0
*/
public interface AuthService<R> {

/**
* Get the authentication user.
*
@@ -30,41 +32,42 @@ public interface AuthService<R> {
AuthUser getAuthUser(R request);

/**
* privilege type.
* Privilege type.
*/
enum PrivilegeType {
/**
* read rule
* Read rule
*/
READ_RULE,
/**
* create or modify rule
* Create or modify rule
*/
WRITE_RULE,
/**
* delete rule
* Delete rule
*/
DELETE_RULE,
/**
* read metrics
* Read metrics
*/
READ_METRIC,
/**
* add machine
* Add machine
*/
ADD_MACHINE,
/**
* equals all privileges above
* All privileges above are granted.
*/
ALL
}

/**
* entity represents the current user
* Represents the current user.
*/
interface AuthUser {

/**
* query whether current user has the specific privilege to the target, the target
* Query whether current user has the specific privilege to the target, the target
* may be an app name or an ip address, or other destination.
* <p>
* This method will use return value to represent whether user has the specific
@@ -80,32 +83,31 @@ public interface AuthService<R> {
boolean authTarget(String target, PrivilegeType privilegeType);

/**
* check whether current user is super user
* Check whether current user is a super-user.
*
* @return if current user is super user return true, else return false.
*/
boolean isSuperUser();

/**
* get current user's nick name.
* Get current user's nick name.
*
* @return current user's nick name.
*/
String getNickName();

/**
* get current user's login name.
* Get current user's login name.
*
* @return current user's login name.
*/
String getLoginName();

/**
* get current user's employ id.
* Get current user's ID.
*
* @return current user's employ id.
* @return ID of current user
*/
String getEmpId();

String getId();
}
}

sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/FakeAuthServiceImpl.java → sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/FakeAuthServiceImpl.java Bestand weergeven

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.csp.sentinel.dashboard.service;
package com.alibaba.csp.sentinel.dashboard.auth;

import javax.servlet.http.HttpServletRequest;

@@ -23,12 +23,13 @@ import org.springframework.stereotype.Component;
* A fake AuthService implementation, which will pass all user auth checking.
*
* @author Carpenter Lee
* @since 1.5.0
*/
@Component
public class FakeAuthServiceImpl implements AuthService<HttpServletRequest> {

@Override
public AuthUser getAuthUser(HttpServletRequest request) {

return new AuthUserImpl();
}

@@ -57,7 +58,7 @@ public class FakeAuthServiceImpl implements AuthService<HttpServletRequest> {
}

@Override
public String getEmpId() {
public String getId() {
return "FAKE_EMP_ID";
}
}

+ 3
- 3
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java Bestand weergeven

@@ -23,15 +23,15 @@ import org.apache.commons.lang.math.NumberUtils;
import org.springframework.lang.NonNull;

/**
* Dashboard config support
* <p>Dashboard local config support.</p>
* <p>
* Dashboard supports configuration loading by several ways by order:<br>
* 1. System.properties<br>
* 2. Env
*
* </p>
*
* @author jason
* @since 1.5.0
*
*/
public class DashboardConfig {



+ 3
- 2
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java Bestand weergeven

@@ -27,8 +27,8 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
import com.alibaba.csp.sentinel.dashboard.service.AuthService;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.AuthUser;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,6 +47,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
public class WebConfig implements WebMvcConfigurer {

private final Logger logger = LoggerFactory.getLogger(WebConfig.class);

@Autowired
private AuthService<HttpServletRequest> authService;



+ 3
- 3
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthorityRuleController.java Bestand weergeven

@@ -22,9 +22,9 @@ import javax.servlet.http.HttpServletRequest;

import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient;
import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo;
import com.alibaba.csp.sentinel.dashboard.service.AuthService;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.util.StringUtil;



+ 3
- 3
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DegradeController.java Bestand weergeven

@@ -22,9 +22,9 @@ import javax.servlet.http.HttpServletRequest;

import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient;
import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo;
import com.alibaba.csp.sentinel.dashboard.service.AuthService;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.util.StringUtil;



+ 3
- 3
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/FlowControllerV1.java Bestand weergeven

@@ -20,9 +20,9 @@ import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.alibaba.csp.sentinel.dashboard.service.AuthService;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.util.StringUtil;

import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient;


+ 3
- 3
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java Bestand weergeven

@@ -27,9 +27,9 @@ import com.alibaba.csp.sentinel.dashboard.client.CommandNotFoundException;
import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient;
import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement;
import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo;
import com.alibaba.csp.sentinel.dashboard.service.AuthService;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
import com.alibaba.csp.sentinel.util.StringUtil;



+ 3
- 3
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java Bestand weergeven

@@ -20,9 +20,9 @@ import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.alibaba.csp.sentinel.dashboard.service.AuthService;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.util.StringUtil;

import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity;


+ 3
- 3
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java Bestand weergeven

@@ -20,9 +20,9 @@ import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.alibaba.csp.sentinel.dashboard.service.AuthService;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.service.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.AuthUser;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.util.StringUtil;

import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity;


Laden…
Annuleren
Opslaan