예제 #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);
  }
예제 #2
0
 public boolean isSecurityEnabled() {
   return goConfigService.isSecurityEnabled();
 }