dist/origin-web-common-services.js
function(projectName, forceRefresh) {
      var deferred = $q.defer();
      currentProject = projectName;
      var projectRules = cachedRulesByProject.get(projectName);
      var rulesResource = "selfsubjectrulesreviews";
      if (!projectRules || projectRules.forceRefresh || forceRefresh) {
        // Check if APIserver contains 'selfsubjectrulesreviews' resource. If not switch to permissive mode.
        if (APIService.apiInfo(rulesResource)) {
          // If a request is already in flight, return the promise for that request.
          if (inFlightRulesRequests[projectName]) {
            return inFlightRulesRequests[projectName];
          }

          Logger.log("AuthorizationService, loading user rules for " + projectName + " project");
          inFlightRulesRequests[projectName] = deferred.promise;
          var resourceGroupVersion = {
            kind: "SelfSubjectRulesReview",
            apiVersion: "v1"
          };
          DataService.create(rulesResource, null, resourceGroupVersion, {namespace: projectName}).then(
            function(data) {
              var normalizedData = normalizeRules(data.status.rules);
              var canUserAddToProject = canAddToProjectCheck(data.status.rules);
              cachedRulesByProject.put(projectName, {rules: normalizedData,
                                                      canAddToProject: canUserAddToProject,
                                                      forceRefresh: false,
                                                      cacheTimestamp: _.now()
                                                    });
              deferred.resolve();
            }, function() {
              permissiveMode = true;
              deferred.resolve();
          }).finally(function() {
            delete inFlightRulesRequests[projectName];
          });
        } else {
          Logger.log("AuthorizationService, resource 'selfsubjectrulesreviews' is not part of APIserver. Switching into permissive mode.");
          permissiveMode = true;
          deferred.resolve();
        }
      } else {
        // Using cached data.
        Logger.log("AuthorizationService, using cached rules for " + projectName + " project");
        if ((_.now() - projectRules.cacheTimestamp) >= 600000) {
          projectRules.forceRefresh = true;
        }
        deferred.resolve();
      }
      return deferred.promise;
    }
function(projectName, forceRefresh) {
      var deferred = $q.defer();
      currentProject = projectName;
      var projectRules = cachedRulesByProject.get(projectName);
      var rulesResource = "selfsubjectrulesreviews";
      if (!projectRules || projectRules.forceRefresh || forceRefresh) {
        // Check if APIserver contains 'selfsubjectrulesreviews' resource. If not switch to permissive mode.
        if (APIService.apiInfo(rulesResource)) {
          // If a request is already in flight, return the promise for that request.
          if (inFlightRulesRequests[projectName]) {
            return inFlightRulesRequests[projectName];
          }

          Logger.log("AuthorizationService, loading user rules for " + projectName + " project");
          inFlightRulesRequests[projectName] = deferred.promise;
          var resourceGroupVersion = {
            kind: "SelfSubjectRulesReview",
            apiVersion: "v1"
          };
          DataService.create(rulesResource, null, resourceGroupVersion, {namespace: projectName}).then(
            function(data) {
              var normalizedData = normalizeRules(data.status.rules);
              var canUserAddToProject = canAddToProjectCheck(data.status.rules);
              cachedRulesByProject.put(projectName, {rules: normalizedData,
                                                      canAddToProject: canUserAddToProject,
                                                      forceRefresh: false,
                                                      cacheTimestamp: _.now()
                                                    });
              deferred.resolve();
            }, function() {
              permissiveMode = true;
              deferred.resolve();
          }).finally(function() {
            delete inFlightRulesRequests[projectName];
          });
        } else {
          Logger.log("AuthorizationService, resource 'selfsubjectrulesreviews' is not part of APIserver. Switching into permissive mode.");
          permissiveMode = true;
          deferred.resolve();
        }
      } else {
        // Using cached data.
        Logger.log("AuthorizationService, using cached rules for " + projectName + " project");
        if ((_.now() - projectRules.cacheTimestamp) >= 600000) {
          projectRules.forceRefresh = true;
        }
        deferred.resolve();
      }
      return deferred.promise;
    }
function ( projectName , forceRefresh ) { var deferred = $q . defer ( ) ; currentProject = projectName ; var projectRules = cachedRulesByProject . get ( projectName ) ; var rulesResource = "selfsubjectrulesreviews" ; if ( ! projectRules || projectRules . forceRefresh || forceRefresh ) { // Check if APIserver contains 'selfsubjectrulesreviews' resource. If not switch to permissive mode. if ( APIService . apiInfo ( rulesResource ) ) { // If a request is already in flight, return the promise for that request. if ( inFlightRulesRequests [ projectName ] ) { return inFlightRulesRequests [ projectName ] ; } Logger . log ( "AuthorizationService, loading user rules for " + projectName + " project" ) ; inFlightRulesRequests [ projectName ] = deferred . promise ; var resourceGroupVersion = { kind : "SelfSubjectRulesReview" , apiVersion : "v1" } ; DataService . create ( rulesResource , null , resourceGroupVersion , { namespace : projectName } ) . then ( function ( data ) { var normalizedData = normalizeRules ( data . status . rules ) ; var canUserAddToProject = canAddToProjectCheck ( data . status . rules ) ; cachedRulesByProject . put ( projectName , { rules : normalizedData , canAddToProject : canUserAddToProject , forceRefresh : false , cacheTimestamp : _ . now ( ) } ) ; deferred . resolve ( ) ; } , function ( ) { permissiveMode = true ; deferred . resolve ( ) ; } ) . finally ( function ( ) { delete inFlightRulesRequests [ projectName ] ; } ) ; } else { Logger . log ( "AuthorizationService, resource 'selfsubjectrulesreviews' is not part of APIserver. Switching into permissive mode." ) ; permissiveMode = true ; deferred . resolve ( ) ; } } else { // Using cached data. Logger . log ( "AuthorizationService, using cached rules for " + projectName + " project" ) ; if ( ( _ . now ( ) - projectRules . cacheTimestamp ) >= 600000 ) { projectRules . forceRefresh = true ; } deferred . resolve ( ) ; } return deferred . promise ; }
forceRefresh is a boolean to bust the cache & request new perms
forceRefresh is a boolean to bust the cache & request new perms