Beispiel #1
0
  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);
  }
Beispiel #2
0
 public boolean stageExists(String pipelineName, String stageName) {
   try {
     stageConfigNamed(pipelineName, stageName);
     return true;
   } catch (StageNotFoundException e) {
     return false;
   }
 }