Skip to content

Commit 1fd5834

Browse files
Revert "[PIP 97] Update Authentication Interfaces to Include Async Authentication Methods (apache#12104)"
This reverts commit 5868025.
1 parent 85b62e0 commit 1fd5834

File tree

3 files changed

+0
-94
lines changed

3 files changed

+0
-94
lines changed

pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationDataSource.java

-3
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ default String getCommandData() {
102102
/**
103103
* Evaluate and challenge the data that passed in, and return processed data back.
104104
* It is used for mutual authentication like SASL.
105-
* NOTE: this method is not called by the Pulsar authentication framework.
106-
* @deprecated use {@link AuthenticationProvider} or {@link AuthenticationState}.
107105
*/
108-
@Deprecated
109106
default AuthData authenticate(AuthData data) throws AuthenticationException {
110107
throw new AuthenticationException("Not supported");
111108
}

pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProvider.java

-56
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@
2121
import java.io.Closeable;
2222
import java.io.IOException;
2323
import java.net.SocketAddress;
24-
import java.util.concurrent.CompletableFuture;
2524
import javax.naming.AuthenticationException;
2625
import javax.net.ssl.SSLSession;
2726
import javax.servlet.http.HttpServletRequest;
2827
import javax.servlet.http.HttpServletResponse;
2928
import org.apache.pulsar.broker.ServiceConfiguration;
3029
import org.apache.pulsar.common.api.AuthData;
31-
import org.apache.pulsar.common.classification.InterfaceStability;
32-
import org.apache.pulsar.common.util.FutureUtil;
3330

3431
/**
3532
* Provider of authentication mechanism.
@@ -51,29 +48,6 @@ public interface AuthenticationProvider extends Closeable {
5148
*/
5249
String getAuthMethodName();
5350

54-
/**
55-
* Validate the authentication for the given credentials with the specified authentication data.
56-
* This method is useful in one stage authentication, if you're not doing one stage or if you're providing
57-
* your own state implementation for one stage authentication, it should return a failed future.
58-
*
59-
* <p>Warning: the calling thread is an IO thread. Any implementation that relies on blocking behavior
60-
* must ensure that the execution is completed using a separate thread pool to ensure IO threads
61-
* are never blocked.</p>
62-
*
63-
* @param authData authentication data generated while initiating a connection. There are several types,
64-
* including, but not strictly limited to, {@link AuthenticationDataHttp},
65-
* {@link AuthenticationDataHttps}, and {@link AuthenticationDataCommand}.
66-
* @return A completed future with the "role" string for the authenticated connection, if authentication is
67-
* successful, or a failed future if the authData is not valid.
68-
*/
69-
default CompletableFuture<String> authenticateAsync(AuthenticationDataSource authData) {
70-
try {
71-
return CompletableFuture.completedFuture(this.authenticate(authData));
72-
} catch (AuthenticationException e) {
73-
return FutureUtil.failedFuture(e);
74-
}
75-
}
76-
7751
/**
7852
* Validate the authentication for the given credentials with the specified authentication data.
7953
* This method is useful in one stage authn, if you're not doing one stage or if you're providing
@@ -84,9 +58,7 @@ default CompletableFuture<String> authenticateAsync(AuthenticationDataSource aut
8458
* @return the "role" string for the authenticated connection, if the authentication was successful
8559
* @throws AuthenticationException
8660
* if the credentials are not valid
87-
* @deprecated use and implement {@link AuthenticationProvider#authenticateAsync(AuthenticationDataSource)} instead.
8861
*/
89-
@Deprecated
9062
default String authenticate(AuthenticationDataSource authData) throws AuthenticationException {
9163
throw new AuthenticationException("Not supported");
9264
}
@@ -101,38 +73,10 @@ default AuthenticationState newAuthState(AuthData authData,
10173
return new OneStageAuthenticationState(authData, remoteAddress, sslSession, this);
10274
}
10375

104-
/**
105-
* Validate the authentication for the given credentials with the specified authentication data.
106-
*
107-
* <p>Warning: the calling thread is an IO thread. Any implementations that rely on blocking behavior
108-
* must ensure that the execution is completed on using a separate thread pool to ensure IO threads
109-
* are never blocked.</p>
110-
*
111-
* <p>Note: this method is marked as unstable because the Pulsar code base only calls it for the
112-
* Pulsar Broker Auth SASL plugin. All non SASL HTTP requests are authenticated using the
113-
* {@link AuthenticationProvider#authenticateAsync(AuthenticationDataSource)} method. As such,
114-
* this method might be removed in favor of the SASL provider implementing the
115-
* {@link AuthenticationProvider#authenticateAsync(AuthenticationDataSource)} method.</p>
116-
*
117-
* @return Set response, according to passed in request.
118-
* and return whether we should do following chain.doFilter or not.
119-
*/
120-
@InterfaceStability.Unstable
121-
default CompletableFuture<Boolean> authenticateHttpRequestAsync(HttpServletRequest request,
122-
HttpServletResponse response) {
123-
try {
124-
return CompletableFuture.completedFuture(this.authenticateHttpRequest(request, response));
125-
} catch (Exception e) {
126-
return FutureUtil.failedFuture(e);
127-
}
128-
}
129-
13076
/**
13177
* Set response, according to passed in request.
13278
* and return whether we should do following chain.doFilter or not.
133-
* @deprecated use and implement {@link AuthenticationProvider#authenticateHttpRequestAsync} instead.
13479
*/
135-
@Deprecated
13680
default boolean authenticateHttpRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
13781
throw new AuthenticationException("Not supported");
13882
}

pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationState.java

-35
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919

2020
package org.apache.pulsar.broker.authentication;
2121

22-
import java.util.concurrent.CompletableFuture;
2322
import javax.naming.AuthenticationException;
2423
import org.apache.pulsar.common.api.AuthData;
25-
import org.apache.pulsar.common.util.FutureUtil;
2624

2725
/**
2826
* Interface for authentication state.
@@ -40,50 +38,17 @@ public interface AuthenticationState {
4038

4139
/**
4240
* Challenge passed in auth data and get response data.
43-
* @deprecated use and implement {@link AuthenticationState#authenticateAsync(AuthData)} instead.
4441
*/
45-
@Deprecated
4642
AuthData authenticate(AuthData authData) throws AuthenticationException;
4743

48-
/**
49-
* Challenge passed in auth data. If authentication is complete after the execution of this method, return null.
50-
* Otherwise, return response data to be sent to the client.
51-
*
52-
* <p>Note: the implementation of {@link AuthenticationState#authenticate(AuthData)} converted a null result into a
53-
* zero length byte array when {@link AuthenticationState#isComplete()} returned false after authentication. In
54-
* order to simplify this interface, the determination of whether to send a challenge back to the client is only
55-
* based on the result of this method. In order to maintain backwards compatibility, the default implementation of
56-
* this method calls {@link AuthenticationState#isComplete()} and returns a result compliant with the new
57-
* paradigm.</p>
58-
*/
59-
default CompletableFuture<AuthData> authenticateAsync(AuthData authData) {
60-
try {
61-
AuthData result = this.authenticate(authData);
62-
if (isComplete()) {
63-
return CompletableFuture.completedFuture(null);
64-
} else {
65-
return result != null
66-
? CompletableFuture.completedFuture(result)
67-
: CompletableFuture.completedFuture(AuthData.of(new byte[0]));
68-
}
69-
} catch (Exception e) {
70-
return FutureUtil.failedFuture(e);
71-
}
72-
}
73-
7444
/**
7545
* Return AuthenticationDataSource.
7646
*/
7747
AuthenticationDataSource getAuthDataSource();
7848

7949
/**
8050
* Whether the authentication is completed or not.
81-
* @deprecated this method's logic is captured by the result of
82-
* {@link AuthenticationState#authenticateAsync(AuthData)}. When the result is a {@link CompletableFuture} with a
83-
* null result, authentication is complete. When the result is a {@link CompletableFuture} with a nonnull result,
84-
* authentication is incomplete and requires an auth challenge.
8551
*/
86-
@Deprecated
8752
boolean isComplete();
8853

8954
/**

0 commit comments

Comments
 (0)