spark
spark copied to clipboard
[SPARK-39820][SQL] Add the Support for Custom Authentication for Thrift Server using Http Servlet Request
What changes were proposed in this pull request?
As per the CustomAuthentication(hive.server2.transport.mode=HTTP) in Thrift Server only String username and String password is supported in the authenticate method of PasswdAuthenticationProvider(https://github.com/apache/spark/blob/master/sql/hive-thriftserver/src/main/java/org/apache/hive/service/auth/PasswdAuthenticationProvider.java#L37). There is no support for the getting Header param of Request, input param of request, request URI, getMethod if these param is required by the Custom Authentication Service(third party sdk, In House Authentication Service).
In order to support CustomAuthentication for Custom Authentication Service(third party Authentication sdk, In House Authentication Service) there is need to add the code change in Spark Code , then only user can add the Custom Authentication.
Why are the changes needed?
There is need to support void AuthenticateRequest(HttpServletRequest request) in the Spark Code base, to integrate the custom Authentication in apache spark For eg
public class SampleAuthenticator implements PasswdAuthenticationProvider {
static Logger logger = Logger.getLogger(SampleAuthenticator.class.getName());
public SampleAuthenticator() {
logger.log(Level.INFO, "initialize SampleAuthenticator");
}
@Override
public void Authenticate(String user, String password)
throws AuthenticationException {
}
@Override
public void AuthenticateRequest(HttpServletRequest request)
throws AuthenticationException {
Map<String, List<String>> requestHeaders = new HashMap();
// derrive the request headerValue from the HttpServletRequest request
logger.log(Level.INFO, "SampleAuthenticator AuthenticateRequest");
dummyAuthenticate(request.getMethod(), requestHeaders, request.getRequestURI());
}
public void dummyAuthenticate(String httpMethod, Map<String, List<String>> requestHeaders, String uri) {
// Code added for custom Authentication
}
}
Does this PR introduce any user-facing change?
No
How was this patch tested?
Manually tested the patch by using above code .
cc @yaooqinn, @cloud-fan, @HyukjinKwon
Can one of the admins verify this patch?
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable. If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!