-
Gabor Somogyi authored
## What changes were proposed in this pull request? If spark is run with "spark.authenticate=true", then it will fail to start in local mode. This PR generates secret in local mode when authentication on. ## How was this patch tested? Modified existing unit test. Manually started spark-shell. Author: Gabor Somogyi <gabor.g.somogyi@gmail.com> Closes #20652 from gaborgsomogyi/SPARK-23476.
Gabor Somogyi authored## What changes were proposed in this pull request? If spark is run with "spark.authenticate=true", then it will fail to start in local mode. This PR generates secret in local mode when authentication on. ## How was this patch tested? Modified existing unit test. Manually started spark-shell. Author: Gabor Somogyi <gabor.g.somogyi@gmail.com> Closes #20652 from gaborgsomogyi/SPARK-23476.
layout: global
displayTitle: Spark Security
title: Security
Spark currently supports authentication via a shared secret. Authentication can be configured to be on via the spark.authenticate
configuration parameter. This parameter controls whether the Spark communication protocols do authentication using the shared secret. This authentication is a basic handshake to make sure both sides have the same shared secret and are allowed to communicate. If the shared secret is not identical they will not be allowed to communicate. The shared secret is created as follows:
- For Spark on YARN and local deployments, configuring
spark.authenticate
totrue
will automatically handle generating and distributing the shared secret. Each application will use a unique shared secret. - For other types of Spark deployments, the Spark parameter
spark.authenticate.secret
should be configured on each of the nodes. This secret will be used by all the Master/Workers and applications.
Web UI
The Spark UI can be secured by using javax servlet filters via the spark.ui.filters
setting
and by using https/SSL via SSL settings.
Authentication
A user may want to secure the UI if it has data that other users should not be allowed to see. The javax servlet filter specified by the user can authenticate the user and then once the user is logged in, Spark can compare that user versus the view ACLs to make sure they are authorized to view the UI. The configs spark.acls.enable
, spark.ui.view.acls
and spark.ui.view.acls.groups
control the behavior of the ACLs. Note that the user who started the application always has view access to the UI. On YARN, the Spark UI uses the standard YARN web application proxy mechanism and will authenticate via any installed Hadoop filters.
Spark also supports modify ACLs to control who has access to modify a running Spark application. This includes things like killing the application or a task. This is controlled by the configs spark.acls.enable
, spark.modify.acls
and spark.modify.acls.groups
. Note that if you are authenticating the web UI, in order to use the kill button on the web UI it might be necessary to add the users in the modify acls to the view acls also. On YARN, the modify acls are passed in and control who has modify access via YARN interfaces.
Spark allows for a set of administrators to be specified in the acls who always have view and modify permissions to all the applications. is controlled by the configs spark.admin.acls
and spark.admin.acls.groups
. This is useful on a shared cluster where you might have administrators or support staff who help users debug applications.
Event Logging
If your applications are using event logging, the directory where the event logs go (spark.eventLog.dir
) should be manually created and have the proper permissions set on it. If you want those log files secured, the permissions should be set to drwxrwxrwxt
for that directory. The owner of the directory should be the super user who is running the history server and the group permissions should be restricted to super user group. This will allow all users to write to the directory but will prevent unprivileged users from removing or renaming a file unless they own the file or directory. The event log files will be created by Spark with permissions such that only the user and group have read and write access.
Encryption
Spark supports SSL for HTTP protocols. SASL encryption is supported for the block transfer service and the RPC endpoints. Shuffle files can also be encrypted if desired.
SSL Configuration
Configuration for SSL is organized hierarchically. The user can configure the default SSL settings
which will be used for all the supported communication protocols unless they are overwritten by
protocol-specific settings. This way the user can easily provide the common settings for all the
protocols without disabling the ability to configure each one individually. The common SSL settings
are at spark.ssl
namespace in Spark configuration. The following table describes the
component-specific configuration namespaces used to override the default settings:
Config Namespace | Component |
---|---|
spark.ssl.fs |
File download client (used to download jars and files from HTTPS-enabled servers). |
spark.ssl.ui |
Spark application Web UI |
spark.ssl.standalone |
Standalone Master / Worker Web UI |
spark.ssl.historyServer |
History Server Web UI |
The full breakdown of available SSL options can be found on the configuration page. SSL must be configured on each node and configured for each component involved in communication using the particular protocol.
YARN mode
The key-store can be prepared on the client side and then distributed and used by the executors as the part of the application. It is possible because the user is able to deploy files before the application is started in YARN by using spark.yarn.dist.files
or spark.yarn.dist.archives
configuration settings. The responsibility for encryption of transferring these files is on YARN side and has nothing to do with Spark.
For long-running apps like Spark Streaming apps to be able to write to HDFS, it is possible to pass a principal and keytab to spark-submit
via the --principal
and --keytab
parameters respectively. The keytab passed in will be copied over to the machine running the Application Master via the Hadoop Distributed Cache (securely - if YARN is configured with SSL and HDFS encryption is enabled). The Kerberos login will be periodically renewed using this principal and keytab and the delegation tokens required for HDFS will be generated periodically so the application can continue writing to HDFS.