-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-18061][ThriftServer] Add spnego auth support for ThriftServer thrift/http protocol #18628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import scala.collection.JavaConverters._ | |
|
|
||
| import org.apache.commons.logging.Log | ||
| import org.apache.hadoop.hive.conf.HiveConf | ||
| import org.apache.hadoop.hive.conf.HiveConf.ConfVars | ||
| import org.apache.hadoop.hive.shims.Utils | ||
| import org.apache.hadoop.security.UserGroupInformation | ||
| import org.apache.hive.service.{AbstractService, Service, ServiceException} | ||
|
|
@@ -47,6 +48,7 @@ private[hive] class SparkSQLCLIService(hiveServer: HiveServer2, sqlContext: SQLC | |
| setSuperField(this, "sessionManager", sparkSqlSessionManager) | ||
| addService(sparkSqlSessionManager) | ||
| var sparkServiceUGI: UserGroupInformation = null | ||
| var httpUGI: UserGroupInformation = null | ||
|
|
||
| if (UserGroupInformation.isSecurityEnabled) { | ||
| try { | ||
|
|
@@ -57,6 +59,19 @@ private[hive] class SparkSQLCLIService(hiveServer: HiveServer2, sqlContext: SQLC | |
| case e @ (_: IOException | _: LoginException) => | ||
| throw new ServiceException("Unable to login to kerberos with given principal/keytab", e) | ||
| } | ||
|
|
||
| // Try creating spnego UGI if it is configured. | ||
| val principal = hiveConf.getVar(ConfVars.HIVE_SERVER2_SPNEGO_PRINCIPAL) | ||
| val keyTabFile = hiveConf.getVar(ConfVars.HIVE_SERVER2_SPNEGO_KEYTAB) | ||
| if (principal.nonEmpty && keyTabFile.nonEmpty) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we log warning if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to avoid calling log APIs using reflection as mentioned in #15594 |
||
| try { | ||
| httpUGI = HiveAuthFactory.loginFromSpnegoKeytabAndReturnUGI(hiveConf) | ||
| setSuperField(this, "httpUGI", httpUGI) | ||
| } catch { | ||
| case e: IOException => | ||
| throw new ServiceException("Unable to login to spnego with given principal/keytab", e) | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd recommend including as much diagnostics in the exception string, including principal & keytab, and the value of e.toString in the message The scenario to plan for is "nothing works and all you have to go on is that string from the raised exception". |
||
| } | ||
| } | ||
|
|
||
| initCompositeService(hiveConf) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HiveConf.getVar()doesn't trim thhe results of leading/trailing via {{Configuration.getTrimmed()}}. Check for other uses of the confvar to see if there is any trimming of whitespace before and after their use: if so, you need to copy that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I searched the code, looks like there's no other place where using
HiveConf.getVartrims the result.