Github user janhoy commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/465#discussion_r223863279
  
    --- Diff: solr/webapp/web/js/angular/app.js ---
    @@ -365,12 +370,62 @@ solrAdminApp.config([
           $rootScope.exceptions[rejection.config.url] = rejection.data.error;
         }
         return $q.reject(rejection);
    -  }
    +  };
    +
    +  return {request: started, response: ended, responseError: failed};
    +})
    +// Intercept authentication request from Solr and forward to /solr/#/login 
   
    +.factory('authInterceptor', function($q, $rootScope, $location, $timeout, 
$injector) {
    +  var started = function(config) {
    +    if (sessionStorage.getItem("auth.header")) {
    +      config.headers['Authorization'] = 
sessionStorage.getItem("auth.header");
    +    }
    +    return config || $q.when(config);
    +  };
    +
    +  var ended = function(response) {
    +    if ($location.path() !== '/login') {
    +      sessionStorage.removeItem("http401");
    +      sessionStorage.removeItem("auth.statusText");
    +    }
    +    return response || $q.when(response);
    +  };
    +
    +  var failed = function(rejection) {
    +    if (rejection.status === 401) {
    +      var headers = rejection.headers();
    +      var wwwAuthHeader = headers['www-authenticate'];
    +      sessionStorage.setItem("auth.wwwAuthHeader", wwwAuthHeader);
    +      sessionStorage.setItem("auth.statusText", rejection.statusText);
    +      var authDataHeader = headers['X-Solr-AuthData'];
    +      if (authDataHeader !== null) {
    +        sessionStorage.setItem("auth.config", authDataHeader);
    +      }
    +      if ($location.path() === '/login') {
    +        sessionStorage.setItem("auth.location", "/");
    --- End diff --
    
    Normally users will be redirected to Login page from whatever page that 
tried to do a restricted API call to Solr, and will be redirected back to that 
page after login. However, if user explicitly navigates to Login tab, this 
makes sure he'll be redirected to Dashboard instead of remaining on the Login 
page.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to