petrov-mg commented on code in PR #10226:
URL: https://github.com/apache/ignite/pull/10226#discussion_r1092306679


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/task/TaskExecutionOptions.java:
##########
@@ -176,13 +176,13 @@ public TaskExecutionOptions asSystemTask() {
     }
 
     /** */
-    public boolean isAuthenticationDisabled() {
-        return isAuthDisabled;
+    public boolean isSystemTaskGuard() {
+        return isSystemTaskGuard;
     }
 
     /** */
-    public TaskExecutionOptions withAuthenticationDisabled() {
-        isAuthDisabled = true;
+    public TaskExecutionOptions withSystemTaskGuard() {
+        isSystemTaskGuard = true;
 
         return this;
     }

Review Comment:
   The option itself is not thread local. 
   Take a look at IgniteComputeImpl, please. We do use TaskExecutionOptions as 
thread local variable here, but isPublicFacade flag is stored separately and 
applied to each compute execution method. So it is safe.



##########
modules/core/src/main/java/org/apache/ignite/internal/IgniteComputeImpl.java:
##########
@@ -68,10 +68,11 @@ public class IgniteComputeImpl extends 
AsyncSupportAdapter<IgniteCompute>
     /** Custom executor name. */
     private String execName;
 
+    /** */
+    private boolean isSysTaskGuard;

Review Comment:
   Fixed. Changed to isPublicFacade.



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java:
##########
@@ -1736,4 +1763,51 @@ else if (!getLocJobStatistics && 
locNodeId.equals(jobResult.getNode().id()))
             return S.toString(GridTaskWorker.class, this);
         }
     }
+
+    /** */
+    private void authorizeSystemJobStart(ComputeJob job) {
+        Object executable = unwrap(job);
+
+        if (!isSystemType(ctx, executable.getClass())) {
+            ctx.security().authorize(executable.getClass().getName(), 
TASK_EXECUTE);
+
+            return;
+        }
+
+        if (executable instanceof SecurityPermissionAware)
+            authorizeAll(ctx.security(), 
((SecurityPermissionAware)executable).requiredPermissions());
+        else if (opts.isSystemTaskGuard()) {
+            throw new SecurityException("Access to Ignite Internal tasks is 
restricted" +
+                " [task=" + task.getClass().getName() + ", job=" + 
executable.getClass() + "]");
+        }
+    }
+
+    /** */
+    public void authorizeTaskCancel() {
+        if (!ctx.security().enabled())
+            return;
+
+        if (!isSystemType(ctx, task.getClass())) {
+            ctx.security().authorize(task.getClass().getName(), TASK_CANCEL);
+
+            return;

Review Comment:
   Fixed.



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java:
##########
@@ -1589,4 +1579,36 @@ public Map<ComputeJobStatusEnum, Long> 
jobStatuses(IgniteUuid sesId) {
         else
             return taskWorker.jobStatuses();
     }
+
+    /** */
+    private void authorizeTaskExecution(String taskName, Class<?> taskCls, 
ComputeTask<?, ?> task) {
+        taskCls = resolveTaskClass(taskName, taskCls, task);
+
+        if (taskCls != null && SecurityUtils.isSystemType(ctx, taskCls))
+            return;

Review Comment:
   Fixed.



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java:
##########
@@ -1736,4 +1763,51 @@ else if (!getLocJobStatistics && 
locNodeId.equals(jobResult.getNode().id()))
             return S.toString(GridTaskWorker.class, this);
         }
     }
+
+    /** */
+    private void authorizeSystemJobStart(ComputeJob job) {
+        Object executable = unwrap(job);
+
+        if (!isSystemType(ctx, executable.getClass())) {
+            ctx.security().authorize(executable.getClass().getName(), 
TASK_EXECUTE);
+
+            return;

Review Comment:
   Fixed.



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/security/SecurityPermissionAware.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import org.apache.ignite.plugin.security.SecurityPermission;
+import org.apache.ignite.plugin.security.SecurityPermissionSet;
+import org.apache.ignite.plugin.security.SecurityPermissionSetBuilder;
+
+/** */
+public interface SecurityPermissionAware {
+    /** */
+    public SecurityPermissionSet NO_PERMISSIONS = 
SecurityPermissionSetBuilder.create().build();
+
+    /** */
+    public SecurityPermissionSet requiredPermissions();
+
+   /** */
+    public static SecurityPermissionSet cachePermissions(String cacheName, 
SecurityPermission... perms) {

Review Comment:
   Fixed.



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/security/SecurityPermissionAware.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import org.apache.ignite.plugin.security.SecurityPermission;
+import org.apache.ignite.plugin.security.SecurityPermissionSet;
+import org.apache.ignite.plugin.security.SecurityPermissionSetBuilder;
+
+/** */
+public interface SecurityPermissionAware {
+    /** */
+    public SecurityPermissionSet NO_PERMISSIONS = 
SecurityPermissionSetBuilder.create().build();

Review Comment:
   Fixed.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to