gerlowskija commented on code in PR #897:
URL: https://github.com/apache/solr/pull/897#discussion_r894507017


##########
solr/core/src/java/org/apache/solr/handler/admin/api/DefaultUpdateAuthenticationConfigAPI.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler.admin.api;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
+import static 
org.apache.solr.security.PermissionNameProvider.Name.SECURITY_EDIT_PERM;
+
+import org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.admin.SecurityConfHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+/**
+ * V2 API for updating the authentication section of Solr's security.json 
configuration.
+ *
+ * <p>Only registered when no authentication plugin is currently registered. 
This API (POST
+ * /v2/cluster/security/authentication) is analogous to the v1 `POST 
/solr/admin/authentication`
+ * API.
+ */
+public class DefaultUpdateAuthenticationConfigAPI {
+  private final SecurityConfHandler securityConfHandler;
+
+  public DefaultUpdateAuthenticationConfigAPI(SecurityConfHandler 
securityConfHandler) {
+    this.securityConfHandler = securityConfHandler;
+  }
+
+  @EndPoint(
+      path = {"/cluster/security/authentication"},
+      method = POST,
+      permission = SECURITY_EDIT_PERM)
+  public void updateAuthenticationConfig(SolrQueryRequest req, 
SolrQueryResponse rsp)

Review Comment:
   Doing a little more digging here, it looks like SecurityConfHandler actually 
has other logic that will short circuit this case (i.e. a POST to 
/authentication or /authorization when no plugin is configured) with a 400 (see 
[here](https://github.com/apache/solr/blob/main/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java#L100)).
   
   Afaict, the only purpose these classes (and the apispecs they came from) 
serve is to make sure users get a helpful error message about "No plugin being 
configured", rather than the less-helpful 404 users would get if no API was 
registered at all until a plugin was registered.
   
   This also explains why the original apispecs didn't list any commands: 
because the API was only a placeholder to produce a comprehensible error 
message, it never offered actual functionality.  I'm going to rename these 
classes and add Javadocs so this is all clearer.  But I don't think I'll be 
able to change the concrete-payload-class thing, unless there's something I'm 
still missing?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to