You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/06/07 16:12:52 UTC
[GitHub] [solr] gerlowskija opened a new pull request, #897: SOLR-15738: Convert v2 security APIs to annotations
gerlowskija opened a new pull request, #897:
URL: https://github.com/apache/solr/pull/897
# Description
Solr's been in the slow process of moving its v2 APIs away from the
existing apispec/mapping framework towards one that relies on more
explicit annotations to specify API properties. Many security APIs
remain on the "old" framework.
# Solution
This commit converts the APIs from the cluster.security.authentication
and cluster.security.authorization apispec files to the "new" framework.
Several other security apispec files still remain, including:
- cluster.security.BasicAuth.Commands
- cluster.security.JwtAuth.Commands
- cluster.security.MultiPluginAuth.Commands
- cluster.security.RuleBasedAuthorization
- cluster.security.authentication.Commands
- cluster.security.authorization.Commands
The first four entries in the list above are plugin-specific commands
for the `POST /cluster/security/[authentication|authorization]`
endpoints. The last two entries (c.s.authentication.Commands and
c.s.authorization.Commands) are fallbacks for the POST endpoints, to
cover the case where no authc/authz plugins are defined. It's unclear
whether or not these are needed going forward.
The aim is to convert all of these apispec files in this PR.
# Tests
None yet, but I intend to add some prior to merging.
# Checklist
Please review the following and check all that apply:
- [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
- [x] I have created a Jira issue and added the issue ID to my pull request title.
- [x] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
- [x] I have developed this patch against the `main` branch.
- [ ] I have run `./gradlew check`.
- [ ] I have added tests for my changes.
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] gerlowskija commented on a diff in pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] gerlowskija merged pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
gerlowskija merged PR #897:
URL: https://github.com/apache/solr/pull/897
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] noblepaul commented on a diff in pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
noblepaul commented on code in PR #897:
URL: https://github.com/apache/solr/pull/897#discussion_r894057481
##########
solr/core/src/java/org/apache/solr/api/AnnotatedApi.java:
##########
@@ -335,6 +337,33 @@ void invoke(SolrQueryRequest req, SolrQueryResponse rsp, CommandOperation cmd) {
}
}
+ public int hashCode() {
Review Comment:
don't you think we should cash and reuse the hash ?
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] noblepaul commented on a diff in pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
noblepaul commented on code in PR #897:
URL: https://github.com/apache/solr/pull/897#discussion_r891806640
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetAuthenticationConfigAPI.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.admin.SecurityConfHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+import static org.apache.solr.security.PermissionNameProvider.Name.SECURITY_READ_PERM;
+
+/**
+ * V2 API for fetching the authentication section from Solr's security.json configuration.
+ *
+ * <p>This API (GET /v2/cluster/security/authentication) is analogous to the v1 `GET /solr/admin/authentication` API.
Review Comment:
let's stick to the `/api/*` prefix instead of `/v2/*` prefix ?
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] noblepaul commented on pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
noblepaul commented on PR #897:
URL: https://github.com/apache/solr/pull/897#issuecomment-1149301465
Do we really need separate classes for specifying the `EndPoint` ? can we just make them internal to `SeciurityCOnfHandler` ?
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] gerlowskija commented on pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
gerlowskija commented on PR #897:
URL: https://github.com/apache/solr/pull/897#issuecomment-1151391577
> Do we really need separate classes for specifying the `EndPoint` ? can we just make them internal to `SeciurityConfHandler` ?
The API classes can be internal if there's consensus for that, but my personal vote would be that they stay separate.
1. The current mapping of APIs -> RequestHandlers is based entirely on the v1 API without any consideration of v2. There's no reason in a v2 world for the `GET /cluster/aliases` API to live in CollectionsHandler.java.
2. Many of our RequestHandler's are absolute monsters. The more code we can keep out of those files, the better IMO. Particularly since one of my ultimate goals is to see the "meat" of our APIs move from SomeRequestHandler.handleRequestBody to these individual API classes.
> We should have concrete POJOs that describe the payloads ?
We do, yep. You didn't see any at the time of your previous comment because I had only pushed up 2 of the `GET` APIs at that point (which of course don't have payloads). I've updated the PR to cover all of the security APIs, so you should see payload POJOs now if you take another look (e.g. `JWTConfigurationPayload`, `UpdateRuleBasedAuthPermissionPayload`, etc.)
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] gerlowskija commented on pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
gerlowskija commented on PR #897:
URL: https://github.com/apache/solr/pull/897#issuecomment-1161932501
Alright, thanks for the reviews guys. Gonna merge this and close out the ticket. Only a few more conversions to do!
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] gerlowskija commented on a diff in pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
gerlowskija commented on code in PR #897:
URL: https://github.com/apache/solr/pull/897#discussion_r893728393
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetAuthenticationConfigAPI.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.admin.SecurityConfHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+import static org.apache.solr.security.PermissionNameProvider.Name.SECURITY_READ_PERM;
+
+/**
+ * V2 API for fetching the authentication section from Solr's security.json configuration.
+ *
+ * <p>This API (GET /v2/cluster/security/authentication) is analogous to the v1 `GET /solr/admin/authentication` API.
Review Comment:
I've always had the slightest preference for `/v2`, because while v1 and v2 both exist, it's easy to imagine a user getting confused and looking for a v1 endpoint under the `/api` path, because hey, it is an api after all. But that's very hypothetical and not something I care much about. But if you guys do, I'm happy to change all of these instances to one or the other.
Just lmk which one wins out and I'll do a separate PR to find-replace it everywhere (it's going to be in a ton of places).
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] epugh commented on a diff in pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
epugh commented on code in PR #897:
URL: https://github.com/apache/solr/pull/897#discussion_r895023670
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetAuthenticationConfigAPI.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.admin.SecurityConfHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+import static org.apache.solr.security.PermissionNameProvider.Name.SECURITY_READ_PERM;
+
+/**
+ * V2 API for fetching the authentication section from Solr's security.json configuration.
+ *
+ * <p>This API (GET /v2/cluster/security/authentication) is analogous to the v1 `GET /solr/admin/authentication` API.
Review Comment:
Makes sense!
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] gerlowskija commented on a diff in pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
gerlowskija commented on code in PR #897:
URL: https://github.com/apache/solr/pull/897#discussion_r894581097
##########
solr/core/src/java/org/apache/solr/handler/admin/api/DefaultUpdateAuthorizationConfigAPI.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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 authorization section of Solr's security.json configuration.
+ *
+ * <p>Only registered when no authorization plugin is currently registered. This API (POST
+ * /v2/cluster/security/authorization) is analogous to the v1 `POST /solr/admin/authorization` API.
+ */
+public class DefaultUpdateAuthorizationConfigAPI {
+ private final SecurityConfHandler securityConfHandler;
+
+ public DefaultUpdateAuthorizationConfigAPI(SecurityConfHandler securityConfHandler) {
+ this.securityConfHandler = securityConfHandler;
+ }
+
+ @EndPoint(
+ path = {"/cluster/security/authorization"},
+ method = POST,
+ permission = SECURITY_EDIT_PERM)
+ public void updateAuthorizationConfig(SolrQueryRequest req, SolrQueryResponse rsp)
Review Comment:
(See my reply on DefaultUpdateAuthenticationConfigAPI above)
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] noblepaul commented on a diff in pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
noblepaul commented on code in PR #897:
URL: https://github.com/apache/solr/pull/897#discussion_r894057742
##########
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:
can't we have concrete classes as params ?
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] epugh commented on a diff in pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
epugh commented on code in PR #897:
URL: https://github.com/apache/solr/pull/897#discussion_r892296044
##########
solr/core/src/java/org/apache/solr/handler/admin/api/GetAuthenticationConfigAPI.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.solr.api.EndPoint;
+import org.apache.solr.handler.admin.SecurityConfHandler;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+
+import static org.apache.solr.client.solrj.SolrRequest.METHOD.GET;
+import static org.apache.solr.security.PermissionNameProvider.Name.SECURITY_READ_PERM;
+
+/**
+ * V2 API for fetching the authentication section from Solr's security.json configuration.
+ *
+ * <p>This API (GET /v2/cluster/security/authentication) is analogous to the v1 `GET /solr/admin/authentication` API.
Review Comment:
Interesting point, I think we have the `/v2/` in the other modifications? I checked https://github.com/apache/solr/blob/main/solr/core/src/java/org/apache/solr/handler/admin/api/SchemaBulkModifyAPI.java#L31 for example.
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] noblepaul commented on a diff in pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
noblepaul commented on code in PR #897:
URL: https://github.com/apache/solr/pull/897#discussion_r894057825
##########
solr/core/src/java/org/apache/solr/handler/admin/api/DefaultUpdateAuthorizationConfigAPI.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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 authorization section of Solr's security.json configuration.
+ *
+ * <p>Only registered when no authorization plugin is currently registered. This API (POST
+ * /v2/cluster/security/authorization) is analogous to the v1 `POST /solr/admin/authorization` API.
+ */
+public class DefaultUpdateAuthorizationConfigAPI {
+ private final SecurityConfHandler securityConfHandler;
+
+ public DefaultUpdateAuthorizationConfigAPI(SecurityConfHandler securityConfHandler) {
+ this.securityConfHandler = securityConfHandler;
+ }
+
+ @EndPoint(
+ path = {"/cluster/security/authorization"},
+ method = POST,
+ permission = SECURITY_EDIT_PERM)
+ public void updateAuthorizationConfig(SolrQueryRequest req, SolrQueryResponse rsp)
Review Comment:
concrete classes here too?
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
[GitHub] [solr] gerlowskija commented on a diff in pull request #897: SOLR-15738: Convert v2 security APIs to annotations
Posted by GitBox <gi...@apache.org>.
gerlowskija commented on code in PR #897:
URL: https://github.com/apache/solr/pull/897#discussion_r894482144
##########
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:
Maybe we should, but I'm not sure what they would be. This file is the annotation conversion for `cluster.security.authentication.Commands.json`, which is the POST api loaded when no authentication plugin is in use.
The old apispec file didn't define any commands, and there are no examples in the ref-guide (afaict) that show what commands are supported in the no-authc-plugin case.
So in short, I only did things this way because (1) I don't know what the concrete classes should be, and (2) this had parity with the apispec, so it seemed at least pass-able.
(This is also the situation on DefaultUpdateAuthorizationConfigAPI below)
##########
solr/core/src/java/org/apache/solr/api/AnnotatedApi.java:
##########
@@ -335,6 +337,33 @@ void invoke(SolrQueryRequest req, SolrQueryResponse rsp, CommandOperation cmd) {
}
}
+ public int hashCode() {
Review Comment:
Several of the instance variables we use to compute the hashCode here are non-final. I'd bet those vars are unlikely to change in practice, but I wasn't confident enough in that to put in caching here, just in case.
--
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-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org