You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2021/07/26 17:00:22 UTC
[GitHub] [geode] upthewaterspout commented on a change in pull request #6721: GEODE-9456, GEODE-9452: Authentication Expiration
upthewaterspout commented on a change in pull request #6721:
URL: https://github.com/apache/geode/pull/6721#discussion_r676781717
##########
File path: geode-core/src/upgradeTest/java/org/apache/geode/security/AuthExpirationDUnitTest.java
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.geode.security;
+
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.apache.geode.test.version.VersionManager.CURRENT_VERSION;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.stream.IntStream;
+
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.contrib.java.lang.system.RestoreSystemProperties;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientRegionFactory;
+import org.apache.geode.cache.client.ClientRegionShortcut;
+import org.apache.geode.test.dunit.rules.ClientVM;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.junit.categories.SecurityTest;
+import org.apache.geode.test.junit.rules.ServerStarterRule;
+import org.apache.geode.test.junit.runners.CategoryWithParameterizedRunnerFactory;
+
+@Category({SecurityTest.class})
+@RunWith(Parameterized.class)
+@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
+public class AuthExpirationDUnitTest {
+
+ @Parameterized.Parameter
+ public String clientVersion;
+
+ @Parameterized.Parameters(name = "{0}")
+ public static Collection<String> data() {
+ // only test the current version and the latest released version
+ return Arrays.asList(CURRENT_VERSION, "1.13.3");
+ }
+
+ @Rule
+ public ClusterStartupRule lsRule = new ClusterStartupRule();
+
+
+ @Rule
+ public RestoreSystemProperties restore = new RestoreSystemProperties();
+
+ @Rule
+ public ServerStarterRule server = new ServerStarterRule()
+ .withProperty(SECURITY_MANAGER, ExpirableSecurityManager.class.getName())
+ .withRegion(RegionShortcut.REPLICATE, "region");
+
+ @After
+ public void after() {
+ // make sure after each test, the values of the ExpirationManager are reset
+ ExpirableSecurityManager securityManager =
+ (ExpirableSecurityManager) server.getCache().getSecurityService().getSecurityManager();
+ securityManager.reset();
+ }
+
+ @Test
+ public void clientShouldReAuthenticateWhenCredentialExpiredAndOperationSucceed()
+ throws Exception {
+ ExpirableSecurityManager.EXPIRE_AFTER = 10;
+ int serverPort = server.getPort();
+ ClientVM clientVM = lsRule.startClientVM(0, clientVersion,
+ c -> c.withCredential("data", "data")
+ .withPoolSubscription(true)
+ .withServerConnection(serverPort));
+
+ clientVM.invoke(() -> {
+ ClientCache clientCache = ClusterStartupRule.getClientCache();
+ ClientRegionFactory clientRegionFactory =
+ clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY);
+ Region region = clientRegionFactory.create("region");
+ IntStream.range(0, 100).forEach(i -> {
+ region.put(i, "value" + i);
+ });
+ });
+
+ ExpirableSecurityManager securityManager =
+ (ExpirableSecurityManager) server.getCache().getSecurityService().getSecurityManager();
+
+ // assert that re-authentication happens
+ assertThat(securityManager.isExpired()).isTrue();
Review comment:
It seems like this test has the potential to be flaky. This is assuming that expiration happened somewhere in the middle of the puts, based on a 10 millisecond timeout. Maybe it would be clearer just to have an API on the test security manager to *force* expiration and call that in the middle of the puts? I'm not sure this test needs to use timeouts at all.
##########
File path: geode-old-client-support/src/main/java/com/gemstone/gemfire/OldClientSupportProvider.java
##########
@@ -121,11 +123,21 @@ public Throwable getThrowable(Throwable theThrowable, KnownVersion clientVersion
if (theThrowable == null) {
return theThrowable;
}
+
+ String className = theThrowable.getClass().getName();
+
+ // GEODE-9452, backward compatibility for authentication expiration
+ if (clientVersion.isOlderThan(KnownVersion.GEODE_1_14_0)) {
+ if (className.equals(AuthenticationExpiredException.class.getName())) {
+ return new AuthenticationRequiredException("User authorization attributes not found.");
Review comment:
nice!
--
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: notifications-unsubscribe@geode.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org