public boolean hasOperatePermissionForStage( String pipelineName, String stageName, String username) { if (!goConfigService.isSecurityEnabled()) { return true; } if (!goConfigService.hasStageConfigNamed(pipelineName, stageName)) { return false; } StageConfig stage = goConfigService.stageConfigNamed(pipelineName, stageName); CaseInsensitiveString userName = new CaseInsensitiveString(username); // TODO - #2517 - stage not exist if (stage.hasOperatePermissionDefined()) { CruiseConfig cruiseConfig = goConfigService.getCurrentConfig(); String groupName = goConfigService.findGroupNameByPipeline(new CaseInsensitiveString(pipelineName)); PipelineConfigs group = goConfigService.getCurrentConfig().findGroup(groupName); if (isUserAdmin(new Username(userName)) || isUserAdminOfGroup(userName, group)) { return true; } return goConfigService.readAclBy(pipelineName, stageName).isGranted(userName); } return hasOperatePermissionForPipeline(new CaseInsensitiveString(username), pipelineName); }
public boolean hasViewPermissionForPipeline(Username username, String pipelineName) { String groupName = goConfigService.findGroupNameByPipeline(new CaseInsensitiveString(pipelineName)); if (groupName == null) { return true; } return hasViewPermissionForGroup(CaseInsensitiveString.str(username.getUsername()), groupName); }
public boolean hasOperatePermissionForPipeline( final CaseInsensitiveString username, String pipelineName) { String groupName = goConfigService.findGroupNameByPipeline(new CaseInsensitiveString(pipelineName)); if (groupName == null) { return true; } return hasOperatePermissionForGroup(username, groupName); }