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 2020/02/06 14:52:53 UTC

[GitHub] [ignite] dgarus opened a new pull request #7375: PoC security context spread

dgarus opened a new pull request #7375: PoC security context spread
URL: https://github.com/apache/ignite/pull/7375
 
 
   

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


With regards,
Apache Git Services

[GitHub] [ignite] dgarus commented on a change in pull request #7375: PoC security context spread

Posted by GitBox <gi...@apache.org>.
dgarus commented on a change in pull request #7375: PoC security context spread
URL: https://github.com/apache/ignite/pull/7375#discussion_r384455333
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/security/IgniteSecurityProcessor.java
 ##########
 @@ -125,10 +120,25 @@ public IgniteSecurityProcessor(GridKernalContext ctx, GridSecurityProcessor secP
         return res;
     }
 
+    /** {@inheritDoc} */
+    @Override public SecurityContext securityContext(UUID subjId) {
+        return secPrc.securityContext(subjId);
+    }
+
     /** {@inheritDoc} */
     @Override public SecurityContext authenticateNode(ClusterNode node, SecurityCredentials cred)
         throws IgniteCheckedException {
-        return secPrc.authenticateNode(node, cred);
+        SecurityContext res = secPrc.authenticateNode(node, cred);
+
+        if (res != null) {
+            Map<String, Object> attrs = new HashMap<>(node.attributes());
+
+            attrs.put(ATTR_SECURITY_SUBJECT_ID, res.subject().id());
+
+            ((TcpDiscoveryNode)node).setAttributes(attrs);
 
 Review comment:
   Yes, you are right.
   To avoid this exception, we can, for example, add the IgniteClusterNode#setAttributes method (I've updated the PR).
   I tried to illustrate that we can do placing the existing logic of spreading security context to GridSecurityProcessor, 
   but this PoC doesn't pretend to be a merge-ready approach.

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7375: PoC security context spread

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7375: PoC security context spread
URL: https://github.com/apache/ignite/pull/7375#discussion_r376275593
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/processors/security/impl/TestSecurityProcessor.java
 ##########
 @@ -89,6 +101,38 @@ public TestSecurityProcessor(GridKernalContext ctx, TestSecurityData nodeSecData
                 .setPerms(PERMS.get(cred))
                 .sandboxPermissions(SANDBOX_PERMS.get(cred))
         );
+
+        try {
+            Map<String, Object> attrs = new HashMap<>(node.attributes());
+
+            attrs.put(ATTR_SECURITY_CONTEXT, U.marshal(ctx.marshallerContext().jdkMarshaller(), res));
+
+            ((TcpDiscoveryNode)node).setAttributes(attrs);
+
+            return res;
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
+        }
+    }
+
+    @Override public SecurityContext securityContext(UUID subjId) {
+        ClusterNode node = ctx.discovery().getInjectedDiscoverySpi().getNode(subjId);
+
+        if(node == null)
 
 Review comment:
   Missed space after `if`.

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7375: PoC security context spread

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7375: PoC security context spread
URL: https://github.com/apache/ignite/pull/7375#discussion_r376992257
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/processors/security/InvalidServerTest.java
 ##########
 @@ -37,29 +39,43 @@
     /** Test server name. */
     private static final String TEST_SERVER_NAME = "test_server";
 
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String instanceName,
-            AbstractTestSecurityPluginProvider pluginProv) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(instanceName, pluginProv);
+    /** */
+    @Test
+    public void testInvalidServer() throws Exception {
+        globalAuth = true;
+
+        startServerNode("server1");
+        startServerNode("server2");
+
+        assertThrowsWithCause(() -> startServerNode(TEST_SERVER_NAME), IgniteAuthenticationException.class);
+    }
 
-        cfg.setDiscoverySpi(new TcpDiscoverySpi() {
-            @Override protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) {
-                if (msg instanceof TcpDiscoveryNodeAddedMessage && msg.verified())
-                    TestSecurityProcessor.PERMS.remove(new SecurityCredentials(TEST_SERVER_NAME, ""));
+    private IgniteEx startServerNode(String login) throws Exception {
+        TestSecurityPluginProvider provider = new TestSecurityPluginProvider(login, "",
+            ALLOW_ALL, null, globalAuth){
+            @Override protected GridSecurityProcessor securityProcessor(GridKernalContext ctx) {
+                return new InvalidServerSecurityProcessor(ctx, super.securityProcessor(ctx));
             }
-        }.setIpFinder(LOCAL_IP_FINDER));
+        };
 
-        return cfg;
+        return startGrid(getConfiguration(login, provider)
+            .setClientMode(false));
     }
 
-    /** */
-    @Test
-    public void testInvalidServer() throws Exception {
-        globalAuth = true;
+    /* */
 
 Review comment:
   Asterisk missed.

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7375: PoC security context spread

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7375: PoC security context spread
URL: https://github.com/apache/ignite/pull/7375#discussion_r376991966
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/processors/security/InvalidServerTest.java
 ##########
 @@ -37,29 +39,43 @@
     /** Test server name. */
     private static final String TEST_SERVER_NAME = "test_server";
 
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String instanceName,
-            AbstractTestSecurityPluginProvider pluginProv) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(instanceName, pluginProv);
+    /** */
+    @Test
+    public void testInvalidServer() throws Exception {
+        globalAuth = true;
+
+        startServerNode("server1");
+        startServerNode("server2");
+
+        assertThrowsWithCause(() -> startServerNode(TEST_SERVER_NAME), IgniteAuthenticationException.class);
+    }
 
-        cfg.setDiscoverySpi(new TcpDiscoverySpi() {
-            @Override protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) {
-                if (msg instanceof TcpDiscoveryNodeAddedMessage && msg.verified())
-                    TestSecurityProcessor.PERMS.remove(new SecurityCredentials(TEST_SERVER_NAME, ""));
+    private IgniteEx startServerNode(String login) throws Exception {
+        TestSecurityPluginProvider provider = new TestSecurityPluginProvider(login, "",
+            ALLOW_ALL, null, globalAuth){
+            @Override protected GridSecurityProcessor securityProcessor(GridKernalContext ctx) {
+                return new InvalidServerSecurityProcessor(ctx, super.securityProcessor(ctx));
             }
-        }.setIpFinder(LOCAL_IP_FINDER));
+        };
 
-        return cfg;
+        return startGrid(getConfiguration(login, provider)
+            .setClientMode(false));
     }
 
-    /** */
-    @Test
-    public void testInvalidServer() throws Exception {
-        globalAuth = true;
+    /* */
+    static class InvalidServerSecurityProcessor extends TestSecurityProcessor.TestSecurityProcessorDelegator {
+
 
 Review comment:
   Redundant empty line.

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7375: PoC security context spread

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7375: PoC security context spread
URL: https://github.com/apache/ignite/pull/7375#discussion_r376275549
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/processors/security/InvalidServerTest.java
 ##########
 @@ -37,29 +39,43 @@
     /** Test server name. */
     private static final String TEST_SERVER_NAME = "test_server";
 
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String instanceName,
-            AbstractTestSecurityPluginProvider pluginProv) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(instanceName, pluginProv);
+    /** */
+    @Test
+    public void testInvalidServer() throws Exception {
+        globalAuth = true;
+
+        startServerNode("server1");
+        startServerNode("server2");
+
+        assertThrowsWithCause(() -> startServerNode(TEST_SERVER_NAME), IgniteAuthenticationException.class);
+    }
 
-        cfg.setDiscoverySpi(new TcpDiscoverySpi() {
-            @Override protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) {
-                if (msg instanceof TcpDiscoveryNodeAddedMessage && msg.verified())
-                    TestSecurityProcessor.PERMS.remove(new SecurityCredentials(TEST_SERVER_NAME, ""));
+    private IgniteEx startServerNode(String login) throws Exception {
+        TestSecurityPluginProvider provider = new TestSecurityPluginProvider(login, "",
+            ALLOW_ALL, null, globalAuth){
+            @Override protected GridSecurityProcessor securityProcessor(GridKernalContext ctx) {
+                return new InvalidServerSecurityProcessor(ctx, super.securityProcessor(ctx));
             }
-        }.setIpFinder(LOCAL_IP_FINDER));
+        };
 
-        return cfg;
+        return startGrid(getConfiguration(login, provider)
+            .setClientMode(false));
     }
 
-    /** */
-    @Test
-    public void testInvalidServer() throws Exception {
-        globalAuth = true;
+    /* */
+    static class InvalidServerSecurityProcessor extends TestSecurityProcessor.TestSecurityProcessorDelegator {
+
+        public InvalidServerSecurityProcessor(GridKernalContext ctx,
+            GridSecurityProcessor original) {
+            super(ctx, original);
+        }
 
-        startGridAllowAll("server1");
-        startGridAllowAll("server2");
+        @Override public SecurityContext authenticateNode(ClusterNode node,
+            SecurityCredentials cred) throws IgniteCheckedException {
+            if(TEST_SERVER_NAME.equals(cred.getLogin()) && !TEST_SERVER_NAME.equals(ctx.igniteInstanceName()))
 
 Review comment:
   Missed space after `if`.

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


With regards,
Apache Git Services

[GitHub] [ignite] ascherbakoff commented on a change in pull request #7375: PoC security context spread

Posted by GitBox <gi...@apache.org>.
ascherbakoff commented on a change in pull request #7375: PoC security context spread
URL: https://github.com/apache/ignite/pull/7375#discussion_r384403072
 
 

 ##########
 File path: modules/core/src/main/java/org/apache/ignite/internal/processors/security/IgniteSecurityProcessor.java
 ##########
 @@ -125,10 +120,25 @@ public IgniteSecurityProcessor(GridKernalContext ctx, GridSecurityProcessor secP
         return res;
     }
 
+    /** {@inheritDoc} */
+    @Override public SecurityContext securityContext(UUID subjId) {
+        return secPrc.securityContext(subjId);
+    }
+
     /** {@inheritDoc} */
     @Override public SecurityContext authenticateNode(ClusterNode node, SecurityCredentials cred)
         throws IgniteCheckedException {
-        return secPrc.authenticateNode(node, cred);
+        SecurityContext res = secPrc.authenticateNode(node, cred);
+
+        if (res != null) {
+            Map<String, Object> attrs = new HashMap<>(node.attributes());
+
+            attrs.put(ATTR_SECURITY_SUBJECT_ID, res.subject().id());
+
+            ((TcpDiscoveryNode)node).setAttributes(attrs);
 
 Review comment:
   The approach looks wrong.
   What if we have ZK discovery SPI ?
   This will trigger class cast exception.

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7375: PoC security context spread

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7375: PoC security context spread
URL: https://github.com/apache/ignite/pull/7375#discussion_r376992354
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/processors/security/InvalidServerTest.java
 ##########
 @@ -37,29 +39,43 @@
     /** Test server name. */
     private static final String TEST_SERVER_NAME = "test_server";
 
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String instanceName,
-            AbstractTestSecurityPluginProvider pluginProv) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(instanceName, pluginProv);
+    /** */
+    @Test
+    public void testInvalidServer() throws Exception {
+        globalAuth = true;
+
+        startServerNode("server1");
+        startServerNode("server2");
+
+        assertThrowsWithCause(() -> startServerNode(TEST_SERVER_NAME), IgniteAuthenticationException.class);
+    }
 
-        cfg.setDiscoverySpi(new TcpDiscoverySpi() {
-            @Override protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) {
-                if (msg instanceof TcpDiscoveryNodeAddedMessage && msg.verified())
-                    TestSecurityProcessor.PERMS.remove(new SecurityCredentials(TEST_SERVER_NAME, ""));
+    private IgniteEx startServerNode(String login) throws Exception {
+        TestSecurityPluginProvider provider = new TestSecurityPluginProvider(login, "",
+            ALLOW_ALL, null, globalAuth){
+            @Override protected GridSecurityProcessor securityProcessor(GridKernalContext ctx) {
+                return new InvalidServerSecurityProcessor(ctx, super.securityProcessor(ctx));
             }
-        }.setIpFinder(LOCAL_IP_FINDER));
+        };
 
-        return cfg;
+        return startGrid(getConfiguration(login, provider)
+            .setClientMode(false));
     }
 
-    /** */
-    @Test
-    public void testInvalidServer() throws Exception {
-        globalAuth = true;
+    /* */
+    static class InvalidServerSecurityProcessor extends TestSecurityProcessor.TestSecurityProcessorDelegator {
+
+        public InvalidServerSecurityProcessor(GridKernalContext ctx,
 
 Review comment:
   Missed javadocs.

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


With regards,
Apache Git Services

[GitHub] [ignite] SomeFire commented on a change in pull request #7375: PoC security context spread

Posted by GitBox <gi...@apache.org>.
SomeFire commented on a change in pull request #7375: PoC security context spread
URL: https://github.com/apache/ignite/pull/7375#discussion_r376275243
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/internal/processors/security/InvalidServerTest.java
 ##########
 @@ -37,29 +39,43 @@
     /** Test server name. */
     private static final String TEST_SERVER_NAME = "test_server";
 
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String instanceName,
-            AbstractTestSecurityPluginProvider pluginProv) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(instanceName, pluginProv);
+    /** */
+    @Test
+    public void testInvalidServer() throws Exception {
+        globalAuth = true;
+
+        startServerNode("server1");
+        startServerNode("server2");
+
+        assertThrowsWithCause(() -> startServerNode(TEST_SERVER_NAME), IgniteAuthenticationException.class);
+    }
 
-        cfg.setDiscoverySpi(new TcpDiscoverySpi() {
-            @Override protected void startMessageProcess(TcpDiscoveryAbstractMessage msg) {
-                if (msg instanceof TcpDiscoveryNodeAddedMessage && msg.verified())
-                    TestSecurityProcessor.PERMS.remove(new SecurityCredentials(TEST_SERVER_NAME, ""));
+    private IgniteEx startServerNode(String login) throws Exception {
+        TestSecurityPluginProvider provider = new TestSecurityPluginProvider(login, "",
+            ALLOW_ALL, null, globalAuth){
+            @Override protected GridSecurityProcessor securityProcessor(GridKernalContext ctx) {
+                return new InvalidServerSecurityProcessor(ctx, super.securityProcessor(ctx));
             }
-        }.setIpFinder(LOCAL_IP_FINDER));
+        };
 
-        return cfg;
+        return startGrid(getConfiguration(login, provider)
+            .setClientMode(false));
 
 Review comment:
   Client mode is set to `false` by default.

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


With regards,
Apache Git Services