You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by sr...@apache.org on 2015/03/12 18:06:50 UTC
[04/10] storm git commit: STORM-446: Adding wildcards and a config
plugin for impersonation authorization.
STORM-446: Adding wildcards and a config plugin for impersonation authorization.
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/807e5cf0
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/807e5cf0
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/807e5cf0
Branch: refs/heads/master
Commit: 807e5cf08de94c3d4094a69c9e57b1f8b6cdc550
Parents: 2d6ab7d
Author: Parth Brahmbhatt <br...@gmail.com>
Authored: Fri Feb 27 15:14:13 2015 -0800
Committer: Parth Brahmbhatt <br...@gmail.com>
Committed: Sat Feb 28 16:05:54 2015 -0800
----------------------------------------------------------------------
SECURITY.md | 5 +++--
storm-core/src/clj/backtype/storm/daemon/nimbus.clj | 14 ++++++++++++++
storm-core/src/jvm/backtype/storm/Config.java | 8 ++++++++
.../auth/authorizer/ImpersonationAuthorizer.java | 8 +++++++-
.../security/auth/authorizer/SimpleACLAuthorizer.java | 7 -------
.../security/auth/digest/ServerCallbackHandler.java | 3 ++-
6 files changed, 34 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/807e5cf0/SECURITY.md
----------------------------------------------------------------------
diff --git a/SECURITY.md b/SECURITY.md
index 37a4dae..be18404 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -334,10 +334,11 @@ A storm client may submit requests on behalf of another user. For example, if a
it can do so by leveraging the impersonation feature.In order to submit topology as some other user , you can use `StormSubmitter.submitTopologyAs` API. Alternatively you can use `NimbusClient.getConfiguredClientAs`
to get a nimbus client as some other user and perform any nimbus action(i.e. kill/rebalance/activate/deactivate) using this client.
-`SimpleACLAuthorizer` performs authorization for any user trying to impersonate. To authorize a user for impersonation following acl config needs to be supplied to nimbus as part of storm config.
-If you add a new entry, you need to restart the nimbus for the entry to be effective.
+To ensure only authorized users can perform impersonation you should start nimbus with `nimbus.impersonation.authorizer` set to `backtype.storm.security.auth.authorizer.ImpersonationAuthorizer`.
+The `ImpersonationAuthorizer` uses `nimbus.impersonation.acl` as the acl to authorize users. Following is a sample nimbus config for supporting impersonation:
```yaml
+nimbus.impersonation.authorizer: backtype.storm.security.auth.authorizer.ImpersonationAuthorizer
nimbus.impersonation.acl:
impersonating_user1:
hosts:
http://git-wip-us.apache.org/repos/asf/storm/blob/807e5cf0/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/backtype/storm/daemon/nimbus.clj b/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
index f1b4082..5caf0a3 100644
--- a/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
+++ b/storm-core/src/clj/backtype/storm/daemon/nimbus.clj
@@ -79,6 +79,7 @@
{:conf conf
:inimbus inimbus
:authorization-handler (mk-authorization-handler (conf NIMBUS-AUTHORIZER) conf)
+ :impersonation-authorization-handler (mk-authorization-handler (conf NIMBUS-IMPERSONATION-AUTHORIZER) conf)
:submitted-count (atom 0)
:storm-cluster-state (cluster/mk-storm-cluster-state conf :acls (when
(Utils/isZkAuthenticationConfiguredStormServer
@@ -778,9 +779,22 @@
(defn check-authorization!
([nimbus storm-name storm-conf operation context]
(let [aclHandler (:authorization-handler nimbus)
+ impersonation-authorizer (:impersonation-authorization-handler nimbus)
ctx (or context (ReqContext/context))
check-conf (if storm-conf storm-conf (if storm-name {TOPOLOGY-NAME storm-name}))]
(log-message "[req " (.requestID ctx) "] Access from: " (.remoteAddress ctx) " principal:" (.principal ctx) " op:" operation)
+
+ (if (.isImpersonating ctx)
+ (do
+ (log-warn "principal: " (.realPrincipal ctx) " is trying to impersonate principal: " (.principal ctx))
+ (if impersonation-authorizer
+ (if-not (.permit impersonation-authorizer ctx operation check-conf)
+ (throw (AuthorizationException. (str "principal " (.realPrincipal ctx) " is not authorized to impersonate
+ principal " (.principal ctx) " from host " (.remoteAddress ctx) " Please see SECURITY.MD to learn
+ how to configure impersonation acls."))))
+ (log-warn "impersonation attempt but " NIMBUS-IMPERSONATION-AUTHORIZER " has no authorizer configured. potential
+ security risk, please see SECURITY.MD to learn how to configure impersonation authorizer."))))
+
(if aclHandler
(if-not (.permit aclHandler ctx operation check-conf)
(throw (AuthorizationException. (str operation (if storm-name (str " on topology " storm-name)) " is not authorized")))
http://git-wip-us.apache.org/repos/asf/storm/blob/807e5cf0/storm-core/src/jvm/backtype/storm/Config.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/Config.java b/storm-core/src/jvm/backtype/storm/Config.java
index 1237c28..1655cf6 100644
--- a/storm-core/src/jvm/backtype/storm/Config.java
+++ b/storm-core/src/jvm/backtype/storm/Config.java
@@ -441,6 +441,14 @@ public class Config extends HashMap<String, Object> {
public static final String NIMBUS_AUTHORIZER = "nimbus.authorizer";
public static final Object NIMBUS_AUTHORIZER_SCHEMA = String.class;
+
+ /**
+ * Impersonation user ACL config entries.
+ */
+ public static final String NIMBUS_IMPERSONATION_AUTHORIZER = "nimbus.impersonation.authorizer";
+ public static final Object NIMBUS_IMPERSONATION_AUTHORIZER_SCHEMA = String.class;
+
+
/**
* Impersonation user ACL config entries.
*/
http://git-wip-us.apache.org/repos/asf/storm/blob/807e5cf0/storm-core/src/jvm/backtype/storm/security/auth/authorizer/ImpersonationAuthorizer.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/security/auth/authorizer/ImpersonationAuthorizer.java b/storm-core/src/jvm/backtype/storm/security/auth/authorizer/ImpersonationAuthorizer.java
index 1e947ae..d6431be 100644
--- a/storm-core/src/jvm/backtype/storm/security/auth/authorizer/ImpersonationAuthorizer.java
+++ b/storm-core/src/jvm/backtype/storm/security/auth/authorizer/ImpersonationAuthorizer.java
@@ -13,6 +13,7 @@ import java.util.*;
public class ImpersonationAuthorizer implements IAuthorizer {
private static final Logger LOG = LoggerFactory.getLogger(ImpersonationAuthorizer.class);
+ protected static final String WILD_CARD = "*";
protected Map<String, ImpersonationACL> userImpersonationACL;
protected IPrincipalToLocal _ptol;
@@ -97,12 +98,17 @@ public class ImpersonationAuthorizer implements IAuthorizer {
}
private boolean isAllowedToImpersonateFromHost(Set<String> authorizedHosts, InetAddress remoteAddress) {
- return authorizedHosts.contains(remoteAddress.getCanonicalHostName()) ||
+ return authorizedHosts.contains(WILD_CARD) ||
+ authorizedHosts.contains(remoteAddress.getCanonicalHostName()) ||
authorizedHosts.contains(remoteAddress.getHostName()) ||
authorizedHosts.contains(remoteAddress.getHostAddress());
}
private boolean isAllowedToImpersonateUser(Set<String> authorizedGroups, String userBeingImpersonated) {
+ if(authorizedGroups.contains(WILD_CARD)) {
+ return true;
+ }
+
Set<String> groups = null;
try {
groups = _groupMappingProvider.getGroups(userBeingImpersonated);
http://git-wip-us.apache.org/repos/asf/storm/blob/807e5cf0/storm-core/src/jvm/backtype/storm/security/auth/authorizer/SimpleACLAuthorizer.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/security/auth/authorizer/SimpleACLAuthorizer.java b/storm-core/src/jvm/backtype/storm/security/auth/authorizer/SimpleACLAuthorizer.java
index 25114b9..888eefb 100644
--- a/storm-core/src/jvm/backtype/storm/security/auth/authorizer/SimpleACLAuthorizer.java
+++ b/storm-core/src/jvm/backtype/storm/security/auth/authorizer/SimpleACLAuthorizer.java
@@ -50,7 +50,6 @@ public class SimpleACLAuthorizer implements IAuthorizer {
protected Set<String> _supervisors;
protected IPrincipalToLocal _ptol;
protected IGroupMappingServiceProvider _groupMappingProvider;
- protected ImpersonationAuthorizer _impersonationAuthorizer;
/**
* Invoked once immediately after construction
* @param conf Storm configuration
@@ -69,8 +68,6 @@ public class SimpleACLAuthorizer implements IAuthorizer {
_ptol = AuthUtils.GetPrincipalToLocalPlugin(conf);
_groupMappingProvider = AuthUtils.GetGroupMappingServiceProviderPlugin(conf);
- _impersonationAuthorizer = new ImpersonationAuthorizer();
- _impersonationAuthorizer.prepare(conf);
}
/**
@@ -91,10 +88,6 @@ public class SimpleACLAuthorizer implements IAuthorizer {
String principal = context.principal().getName();
String user = _ptol.toLocal(context.principal());
- if(!_impersonationAuthorizer.permit(context, operation, topology_conf)) {
- return false;
- }
-
if (_admins.contains(principal) || _admins.contains(user)) {
return true;
}
http://git-wip-us.apache.org/repos/asf/storm/blob/807e5cf0/storm-core/src/jvm/backtype/storm/security/auth/digest/ServerCallbackHandler.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/security/auth/digest/ServerCallbackHandler.java b/storm-core/src/jvm/backtype/storm/security/auth/digest/ServerCallbackHandler.java
index 0ff3d35..1788dab 100644
--- a/storm-core/src/jvm/backtype/storm/security/auth/digest/ServerCallbackHandler.java
+++ b/storm-core/src/jvm/backtype/storm/security/auth/digest/ServerCallbackHandler.java
@@ -112,7 +112,7 @@ public class ServerCallbackHandler implements CallbackHandler {
private void handleAuthorizeCallback(AuthorizeCallback ac) {
String authenticationID = ac.getAuthenticationID();
- LOG.info("Successfully authenticated client: authenticationID=" + authenticationID + " authorizationID= " + ac.getAuthorizationID());
+ LOG.info("Successfully authenticated client: authenticationID = " + authenticationID + " authorizationID = " + ac.getAuthorizationID());
//if authorizationId is not set, set it to authenticationId.
if(ac.getAuthorizationID() == null) {
@@ -122,6 +122,7 @@ public class ServerCallbackHandler implements CallbackHandler {
//When authNid and authZid are not equal , authNId is attempting to impersonate authZid, We
//add the authNid as the real user in reqContext's subject which will be used during authorization.
if(!authenticationID.equals(ac.getAuthorizationID())) {
+ LOG.info("Impersonation attempt authenticationID = " + ac.getAuthenticationID() + " authorizationID = " + ac.getAuthorizationID());
ReqContext.context().setRealPrincipal(new SaslTransportPlugin.User(ac.getAuthenticationID()));
}