[ 
https://issues.apache.org/jira/browse/ARTEMIS-3106?focusedWorklogId=568456&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-568456
 ]

ASF GitHub Bot logged work on ARTEMIS-3106:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Mar/21 16:03
            Start Date: 18/Mar/21 16:03
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on a change in pull request #3470:
URL: https://github.com/apache/activemq-artemis/pull/3470#discussion_r597013469



##########
File path: 
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/sasl/SaslScramTest.java
##########
@@ -0,0 +1,94 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.activemq.artemis.tests.integration.amqp.sasl;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
+import 
org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
+import org.apache.qpid.jms.JmsConnectionFactory;
+import org.apache.qpid.jms.exceptions.JMSSecuritySaslException;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This test SASL-SCRAM Support
+ */
+public class SaslScramTest {
+
+   private static EmbeddedActiveMQ BROKER;
+
+   @BeforeClass
+   public static void startBroker() throws Exception {
+      String loginConfPath = new 
File(SaslScramTest.class.getResource("/login.config").toURI()).getAbsolutePath();
+      System.out.println(loginConfPath);
+      System.setProperty("java.security.auth.login.config", loginConfPath);
+      BROKER = new EmbeddedActiveMQ();
+      
BROKER.setConfigResourcePath(SaslScramTest.class.getResource("/broker-saslscram.xml").toExternalForm());
+      BROKER.setSecurityManager(new 
ActiveMQJAASSecurityManager("artemis-sasl-scram"));
+      BROKER.start();
+   }
+
+   @AfterClass
+   public static void shutdownBroker() throws Exception {
+      BROKER.stop();
+   }
+
+   @Test
+   public void testUnencryptedWorksWithAllMechanism() throws JMSException {
+      sendRcv("SCRAM-SHA-1", "hello", "ogre1234");
+      sendRcv("SCRAM-SHA-256", "hello", "ogre1234");
+   }
+
+   @Test(expected = JMSSecuritySaslException.class)
+   public void testEncryptedWorksOnlyWithMechanism() throws JMSException {
+      sendRcv("SCRAM-SHA-1", "test", "test");
+   }
+
+   @Test
+   public void testEncryptedWorksWithMechanism() throws JMSException {
+      sendRcv("SCRAM-SHA-256", "test", "test");
+   }

Review comment:
       The tests names could be more descriptive of what they are doing. I did 
eventually figure out that 'testEncryptedWorksOnlyWithMechanism' and 
'testEncryptedWorksWithMechanism' are 2 paired tests checking that login for 
the 'test' user only works with the SCRAM-SHA-256 mechanism since the details 
were presumably generated for that mech and can only work with that (goes back 
to the comment about indicating how the file contents were created).
   
   That makes me think its a bad idea for it the login module to be able 
support more than one mechanism. The broker generally shouldnt advertise e.g 
both SCRAM-SHA1 and SCRAM-SHA-256 (though what is advertised is obviously under 
the configs control) when using a single module if the credentials for a given 
user can only work with one SCRAM type when stored they way they should be 
(obviously with plaintext storage it could do any). I think it might make more 
sense to have mechanism-specific modules given that.
   
   To that end I would perhaps just skip the SCRAM-SHA-1 support and rename 
everything for 256. It feels like few should consider using it SHA-1 at this 
point a newly introduced setup instead of requiring 256.




-- 
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 568456)
    Time Spent: 8h  (was: 7h 50m)

> Support for SASL-SCRAM
> ----------------------
>
>                 Key: ARTEMIS-3106
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3106
>             Project: ActiveMQ Artemis
>          Issue Type: New Feature
>          Components: AMQP
>            Reporter: Christoph Läubrich
>            Priority: Major
>          Time Spent: 8h
>  Remaining Estimate: 0h
>
> With the enhancements in ARTEMIS-33 / [PR 
> 3432|https://github.com/apache/activemq-artemis/pull/3432] it would be now 
> possible to plug-in new SASL mechanism.
> One popular one is 
> [SASL-SCRAM|https://en.wikipedia.org/wiki/Salted_Challenge_Response_Authentication_Mechanism]
>  because it allows channelbinding together with secure storage of 
> user-credential.
> I have created an [implementation of this for Artemis 
> AMQP|https://github.com/laeubi/scram-sasl/tree/artemis/artemis] based on the 
> [SCRAM SASL authentication for Java|https://github.com/ogrebgr/scram-sasl] 
> code with some enhancements/cleanups to the original.
> As the source is already Apache licensed I'd like to propose to include this 
> in the Artemis code-base. This would greatly enhance the interoperability 
> with other implementations e.g. Apache QPID. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to