You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/05/17 20:23:38 UTC

[GitHub] [ignite] andrey-kuznetsov commented on a change in pull request #9098: IGNITE-14292: Change permissions required to create/destroy caches in GridRestProcessor

andrey-kuznetsov commented on a change in pull request #9098:
URL: https://github.com/apache/ignite/pull/9098#discussion_r633843856



##########
File path: modules/core/src/test/java/org/apache/ignite/internal/processors/security/impl/TestAuthorizationContextSecurityPluginProvider.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.ignite.internal.processors.security.impl;
+
+import java.security.Permissions;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.function.Consumer;
+import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.processors.security.GridSecurityProcessor;
+import org.apache.ignite.internal.processors.security.SecurityContext;
+import org.apache.ignite.plugin.security.SecurityException;
+import org.apache.ignite.plugin.security.SecurityPermission;
+import org.apache.ignite.plugin.security.SecurityPermissionSet;
+
+/**
+ *
+ */
+public class TestAuthorizationContextSecurityPluginProvider extends TestSecurityPluginProvider {
+    /** Authorization handler. */
+    private final Consumer<TestAuthorizationContext> hndlr;
+
+    /** */
+    public TestAuthorizationContextSecurityPluginProvider(String login, String pwd, SecurityPermissionSet perms,
+        boolean globalAuth, Consumer<TestAuthorizationContext> hndlr,
+        TestSecurityData... clientData) {
+        super(login, pwd, perms, globalAuth, clientData);
+
+        this.hndlr = hndlr;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected GridSecurityProcessor securityProcessor(GridKernalContext ctx) {
+        return new TestAuthorizationContextSecurityProcessor(ctx,
+            new TestSecurityData(login, pwd, perms, new Permissions()),
+            Arrays.asList(clientData),
+            globalAuth,
+            hndlr);
+    }
+
+    /**
+     *
+     */
+    public static class TestAuthorizationContext {
+        /** */
+        private final String name;
+
+        /** */
+        private final SecurityPermission perm;
+
+        /** */
+        private final SecurityContext securityCtx;
+
+        /** */
+        public TestAuthorizationContext(String name, SecurityPermission perm,
+            SecurityContext securityCtx) {
+            this.name = name;
+            this.perm = perm;
+            this.securityCtx = securityCtx;
+        }
+
+        /** */
+        public String getName() {

Review comment:
       Getters are redundant to me; public final fields are enough.

##########
File path: modules/rest-http/src/test/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/RestProcessorAuthorizationTest.java
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.ignite.internal.processors.rest.protocols.http.jetty;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.cluster.ClusterState;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.rest.GridRestCommand;
+import org.apache.ignite.internal.processors.rest.GridRestProcessor;
+import org.apache.ignite.internal.processors.security.client.CommonSecurityCheckTest;
+import org.apache.ignite.internal.processors.security.impl.TestAuthorizationContextSecurityPluginProvider;
+import org.apache.ignite.internal.processors.security.impl.TestAuthorizationContextSecurityPluginProvider.TestAuthorizationContext;
+import org.apache.ignite.plugin.PluginProvider;
+import org.apache.ignite.plugin.security.SecurityPermission;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.processors.cache.CacheGetRemoveSkipStoreTest.TEST_CACHE;
+import static org.apache.ignite.plugin.security.SecurityPermissionSetBuilder.ALLOW_ALL;
+
+/**
+ * Tests REST processor authorization commands GET_OR_CREATE_CACHE / DESTROY_CACHE.
+ */
+public class RestProcessorAuthorizationTest extends CommonSecurityCheckTest {
+    /** */
+    private final List<TestAuthorizationContext> hndlr = new ArrayList<>();

Review comment:
       It's not a handler, please rename. (List of authorizations seen)




-- 
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.

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