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

    https://github.com/apache/lucene-solr/pull/457#discussion_r222761691
  
    --- Diff: 
solr/core/src/java/org/apache/solr/security/AuthenticationPlugin.java ---
    @@ -52,11 +80,73 @@
       public abstract boolean doAuthenticate(ServletRequest request, 
ServletResponse response,
           FilterChain filterChain) throws Exception;
     
    +  /**
    +   * This method is called by SolrDispatchFilter in order to initiate 
authentication.
    +   * It does some standard metrics counting.
    +   */
    +  public final boolean authenticate(ServletRequest request, 
ServletResponse response, FilterChain filterChain) throws Exception {
    +    Timer.Context timer = requestTimes.time();
    +    requests.inc();
    +    try {
    +      return doAuthenticate(request, response, filterChain);
    +    } catch(Exception e) {
    +      numErrors.mark();
    +      throw e;
    +    } finally {
    +      long elapsed = timer.stop();
    +      totalTime.inc(elapsed);
    +    }
    +  }
     
       /**
        * Cleanup any per request  data
        */
       public void closeRequest() {
       }
     
    +  @Override
    +  public void initializeMetrics(SolrMetricManager manager, String 
registryName, String tag, final String scope) {
    +    this.metricManager = manager;
    +    this.registryName = registryName;
    +    // Metrics
    +    registry = manager.registry(registryName);
    +    numErrors = manager.meter(this, registryName, "errors", 
getCategory().toString(), scope);
    +    numTimeouts = manager.meter(this, registryName, "timeouts", 
getCategory().toString(), scope);
    +    requests = manager.counter(this, registryName, "requests", 
getCategory().toString(), scope);
    +    numAuthenticated = manager.counter(this, registryName, 
"authenticated", getCategory().toString(), scope);
    +    numPassThrough = manager.counter(this, registryName, "passThrough", 
getCategory().toString(), scope);
    +    numWrongCredentials = manager.counter(this, registryName, 
"failWrongCredentials", getCategory().toString(), scope);
    +    numInvalidCredentials = manager.counter(this, registryName, 
"failInvalidCredentials", getCategory().toString(), scope);
    +    numMissingCredentials = manager.counter(this, registryName, 
"failMissingCredentials", getCategory().toString(), scope);
    +    requestTimes = manager.timer(this, registryName, "requestTimes", 
getCategory().toString(), scope);
    +    totalTime = manager.counter(this, registryName, "totalTime", 
getCategory().toString(), scope);
    +    metricNames.addAll(Arrays.asList("errors", "timeouts", "requests", 
"authenticated", "passThrough",
    +        "failWrongCredentials", "failMissingCredentials", 
"failInvalidCredentials", "requestTimes", "totalTime"));
    +  }
    +  
    +  @Override
    +  public String getName() {
    +    return this.getClass().getName();
    +  }
    +
    +  @Override
    +  public String getDescription() {
    +    return this.getClass().getName();
    --- End diff --
    
    I did not want to extend the API surface of the Auth plugins to require a 
description, Any suggestions of how to obtain better description from somewhere 
else?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to