dashboard: code rearrangement and javadoc refinement
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
parent
53a4e16144
commit
16d92b8821
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue