@@ -29,6 +29,7 @@ import org.apache.hadoop.security.{Credentials, UserGroupInformation}
29
29
import org .apache .spark .deploy .SparkHadoopUtil
30
30
import org .apache .spark .internal .Logging
31
31
import org .apache .spark .internal .config ._
32
+ import org .apache .spark .internal .config .UI ._
32
33
import org .apache .spark .launcher .SparkLauncher
33
34
import org .apache .spark .network .sasl .SecretKeyHolder
34
35
import org .apache .spark .util .Utils
@@ -56,17 +57,13 @@ private[spark] class SecurityManager(
56
57
private val WILDCARD_ACL = " *"
57
58
58
59
private val authOn = sparkConf.get(NETWORK_AUTH_ENABLED )
59
- // keep spark.ui.acls.enable for backwards compatibility with 1.0
60
- private var aclsOn =
61
- sparkConf.getBoolean(" spark.acls.enable" , sparkConf.getBoolean(" spark.ui.acls.enable" , false ))
60
+ private var aclsOn = sparkConf.get(ACLS_ENABLE )
62
61
63
62
// admin acls should be set before view or modify acls
64
- private var adminAcls : Set [String ] =
65
- stringToSet(sparkConf.get(" spark.admin.acls" , " " ))
63
+ private var adminAcls : Set [String ] = sparkConf.get(ADMIN_ACLS ).toSet
66
64
67
65
// admin group acls should be set before view or modify group acls
68
- private var adminAclsGroups : Set [String ] =
69
- stringToSet(sparkConf.get(" spark.admin.acls.groups" , " " ))
66
+ private var adminAclsGroups : Set [String ] = sparkConf.get(ADMIN_ACLS_GROUPS ).toSet
70
67
71
68
private var viewAcls : Set [String ] = _
72
69
@@ -82,11 +79,11 @@ private[spark] class SecurityManager(
82
79
private val defaultAclUsers = Set [String ](System .getProperty(" user.name" , " " ),
83
80
Utils .getCurrentUserName())
84
81
85
- setViewAcls(defaultAclUsers, sparkConf.get(" spark.ui.view.acls " , " " ))
86
- setModifyAcls(defaultAclUsers, sparkConf.get(" spark.modify.acls " , " " ))
82
+ setViewAcls(defaultAclUsers, sparkConf.get(UI_VIEW_ACLS ))
83
+ setModifyAcls(defaultAclUsers, sparkConf.get(MODIFY_ACLS ))
87
84
88
- setViewAclsGroups(sparkConf.get(" spark.ui.view.acls.groups " , " " ));
89
- setModifyAclsGroups(sparkConf.get(" spark.modify.acls.groups " , " " ));
85
+ setViewAclsGroups(sparkConf.get(UI_VIEW_ACLS_GROUPS ))
86
+ setModifyAclsGroups(sparkConf.get(MODIFY_ACLS_GROUPS ))
90
87
91
88
private var secretKey : String = _
92
89
logInfo(" SecurityManager: authentication " + (if (authOn) " enabled" else " disabled" ) +
@@ -127,32 +124,25 @@ private[spark] class SecurityManager(
127
124
opts
128
125
}
129
126
130
- /**
131
- * Split a comma separated String, filter out any empty items, and return a Set of strings
132
- */
133
- private def stringToSet (list : String ): Set [String ] = {
134
- list.split(',' ).map(_.trim).filter(! _.isEmpty).toSet
135
- }
136
-
137
127
/**
138
128
* Admin acls should be set before the view or modify acls. If you modify the admin
139
129
* acls you should also set the view and modify acls again to pick up the changes.
140
130
*/
141
- def setViewAcls (defaultUsers : Set [String ], allowedUsers : String ) {
142
- viewAcls = ( adminAcls ++ defaultUsers ++ stringToSet( allowedUsers))
131
+ def setViewAcls (defaultUsers : Set [String ], allowedUsers : Seq [ String ] ) {
132
+ viewAcls = adminAcls ++ defaultUsers ++ allowedUsers
143
133
logInfo(" Changing view acls to: " + viewAcls.mkString(" ," ))
144
134
}
145
135
146
- def setViewAcls (defaultUser : String , allowedUsers : String ) {
136
+ def setViewAcls (defaultUser : String , allowedUsers : Seq [ String ] ) {
147
137
setViewAcls(Set [String ](defaultUser), allowedUsers)
148
138
}
149
139
150
140
/**
151
141
* Admin acls groups should be set before the view or modify acls groups. If you modify the admin
152
142
* acls groups you should also set the view and modify acls groups again to pick up the changes.
153
143
*/
154
- def setViewAclsGroups (allowedUserGroups : String ) {
155
- viewAclsGroups = ( adminAclsGroups ++ stringToSet( allowedUserGroups));
144
+ def setViewAclsGroups (allowedUserGroups : Seq [ String ] ) {
145
+ viewAclsGroups = adminAclsGroups ++ allowedUserGroups
156
146
logInfo(" Changing view acls groups to: " + viewAclsGroups.mkString(" ," ))
157
147
}
158
148
@@ -179,17 +169,17 @@ private[spark] class SecurityManager(
179
169
* Admin acls should be set before the view or modify acls. If you modify the admin
180
170
* acls you should also set the view and modify acls again to pick up the changes.
181
171
*/
182
- def setModifyAcls (defaultUsers : Set [String ], allowedUsers : String ) {
183
- modifyAcls = ( adminAcls ++ defaultUsers ++ stringToSet( allowedUsers))
172
+ def setModifyAcls (defaultUsers : Set [String ], allowedUsers : Seq [ String ] ) {
173
+ modifyAcls = adminAcls ++ defaultUsers ++ allowedUsers
184
174
logInfo(" Changing modify acls to: " + modifyAcls.mkString(" ," ))
185
175
}
186
176
187
177
/**
188
178
* Admin acls groups should be set before the view or modify acls groups. If you modify the admin
189
179
* acls groups you should also set the view and modify acls groups again to pick up the changes.
190
180
*/
191
- def setModifyAclsGroups (allowedUserGroups : String ) {
192
- modifyAclsGroups = ( adminAclsGroups ++ stringToSet( allowedUserGroups));
181
+ def setModifyAclsGroups (allowedUserGroups : Seq [ String ] ) {
182
+ modifyAclsGroups = adminAclsGroups ++ allowedUserGroups
193
183
logInfo(" Changing modify acls groups to: " + modifyAclsGroups.mkString(" ," ))
194
184
}
195
185
@@ -216,17 +206,17 @@ private[spark] class SecurityManager(
216
206
* Admin acls should be set before the view or modify acls. If you modify the admin
217
207
* acls you should also set the view and modify acls again to pick up the changes.
218
208
*/
219
- def setAdminAcls (adminUsers : String ) {
220
- adminAcls = stringToSet( adminUsers)
209
+ def setAdminAcls (adminUsers : Seq [ String ] ) {
210
+ adminAcls = adminUsers.toSet
221
211
logInfo(" Changing admin acls to: " + adminAcls.mkString(" ," ))
222
212
}
223
213
224
214
/**
225
215
* Admin acls groups should be set before the view or modify acls groups. If you modify the admin
226
216
* acls groups you should also set the view and modify acls groups again to pick up the changes.
227
217
*/
228
- def setAdminAclsGroups (adminUserGroups : String ) {
229
- adminAclsGroups = stringToSet( adminUserGroups)
218
+ def setAdminAclsGroups (adminUserGroups : Seq [ String ] ) {
219
+ adminAclsGroups = adminUserGroups.toSet
230
220
logInfo(" Changing admin acls groups to: " + adminAclsGroups.mkString(" ," ))
231
221
}
232
222
@@ -416,7 +406,7 @@ private[spark] object SecurityManager {
416
406
417
407
val k8sRegex = " k8s.*" .r
418
408
val SPARK_AUTH_CONF = NETWORK_AUTH_ENABLED .key
419
- val SPARK_AUTH_SECRET_CONF = " spark.authenticate.secret "
409
+ val SPARK_AUTH_SECRET_CONF = AUTH_SECRET .key
420
410
// This is used to set auth secret to an executor's env variable. It should have the same
421
411
// value as SPARK_AUTH_SECRET_CONF set in SparkConf
422
412
val ENV_AUTH_SECRET = " _SPARK_AUTH_SECRET"
0 commit comments