You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2021/07/16 22:10:36 UTC
[brooklyn-server] branch master updated (0bab702 -> 0ab9098)
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git.
from 0bab702 make logbook test install log from classpath to temp file
add 784c8ef Adds an attributes map to WebEntitlementContext and use EntitlementContextFilter to sync the user LDAP groups from the session
add 5b88b52 handle no users without groups
add 14c400e Address PR comments
add 3b05194 Address PR comments II
new 33b1331 Changed attributes to a MutableMap
new 48c962a Flated context attributes
new 0ab9098 This closes #1202
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../mgmt/entitlement/WebEntitlementContext.java | 16 ++++-
.../apache/brooklyn/rest/BrooklynWebConfig.java | 5 ++
.../rest/filter/EntitlementContextFilter.java | 33 ++++++---
.../security/provider/LdapSecurityProvider.java | 84 ++++++++++++++++++++--
4 files changed, 119 insertions(+), 19 deletions(-)
[brooklyn-server] 02/03: Flated context attributes
Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit 48c962a98e06781045633763127663a60c26ac03
Author: Juan Cabrerizo <ju...@cloudsoft.io>
AuthorDate: Fri Jul 16 16:41:59 2021 +0100
Flated context attributes
---
.../core/mgmt/entitlement/WebEntitlementContext.java | 5 +----
.../rest/filter/EntitlementContextFilter.java | 20 +++++++-------------
.../rest/security/provider/LdapSecurityProvider.java | 4 ++--
3 files changed, 10 insertions(+), 19 deletions(-)
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/entitlement/WebEntitlementContext.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/entitlement/WebEntitlementContext.java
index a7673ae..f54653c 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/entitlement/WebEntitlementContext.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/entitlement/WebEntitlementContext.java
@@ -22,7 +22,6 @@ import org.apache.brooklyn.api.mgmt.entitlement.EntitlementContext;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.javalang.JavaClassNames;
-import java.util.HashMap;
import java.util.Map;
/**
@@ -31,9 +30,7 @@ import java.util.Map;
*/
public class WebEntitlementContext implements EntitlementContext {
- public static final String ENTITLEMENTS_ATTRIBUTES = "brooklyn.entitlements.attributes";
-
- public static final String USER_ROLES = "brooklyn.entitlements.user.roles";
+ public static final String USER_GROUPS = "brooklyn.entitlements.user.groups";
final String user;
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/filter/EntitlementContextFilter.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/filter/EntitlementContextFilter.java
index a904393..4a8bb67 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/filter/EntitlementContextFilter.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/filter/EntitlementContextFilter.java
@@ -20,8 +20,6 @@ package org.apache.brooklyn.rest.filter;
import java.io.IOException;
import java.security.Principal;
-import java.util.List;
-import java.util.Map;
import javax.annotation.Priority;
import javax.servlet.http.HttpServletRequest;
@@ -33,11 +31,11 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.ext.Provider;
-import com.google.common.collect.ImmutableMap;
import org.apache.brooklyn.api.mgmt.entitlement.EntitlementContext;
import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
import org.apache.brooklyn.core.mgmt.entitlement.WebEntitlementContext;
import org.apache.brooklyn.rest.util.MultiSessionAttributeAdapter;
+import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.text.Strings;;
@Provider
@@ -71,17 +69,13 @@ public class EntitlementContextFilter implements ContainerRequestFilter, Contain
String remoteAddr = request.getRemoteAddr();
String uid = RequestTaggingRsFilter.getTag();
- List<String> userRoles = (List<String>) getAttributeFromSession(WebEntitlementContext.USER_ROLES);
- Map<String, Object> entitlementAttributes = null;
- if (userRoles != null) {
- entitlementAttributes = ImmutableMap.of(
- WebEntitlementContext.ENTITLEMENTS_ATTRIBUTES,
- ImmutableMap.of(
- WebEntitlementContext.USER_ROLES,
- userRoles));
- }
- WebEntitlementContext entitlementContext = new WebEntitlementContext(userName, remoteAddr, uri, uid, entitlementAttributes);
+ WebEntitlementContext entitlementContext = new WebEntitlementContext(
+ userName,
+ remoteAddr,
+ uri,
+ uid,
+ MutableMap.<String, Object>of().addIfNotNull(WebEntitlementContext.USER_GROUPS, getAttributeFromSession(WebEntitlementContext.USER_GROUPS)));
Entitlements.setEntitlementContext(entitlementContext);
}
}
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/security/provider/LdapSecurityProvider.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/security/provider/LdapSecurityProvider.java
index 3d821b7..49cc4e4 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/security/provider/LdapSecurityProvider.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/security/provider/LdapSecurityProvider.java
@@ -44,7 +44,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.brooklyn.core.mgmt.entitlement.WebEntitlementContext.USER_ROLES;
+import static org.apache.brooklyn.core.mgmt.entitlement.WebEntitlementContext.USER_GROUPS;
/**
* A {@link SecurityProvider} implementation that relies on LDAP to authenticate.
@@ -110,7 +110,7 @@ public class LdapSecurityProvider extends AbstractSecurityProvider implements Se
DirContext ctx = new InitialDirContext(env);// will throw if password is invalid
if (fetchUserGroups) {
// adds user groups ot eh session
- sessionSupplierOnSuccess.get().setAttribute(USER_ROLES, getUserGroups(user, ctx));
+ sessionSupplierOnSuccess.get().setAttribute(USER_GROUPS, getUserGroups(user, ctx));
}
return allow(sessionSupplierOnSuccess.get(), user);
} catch (NamingException e) {
[brooklyn-server] 01/03: Changed attributes to a MutableMap
Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit 33b13313819bdc97be08e035f96fb68b100351ad
Author: Juan Cabrerizo <ju...@cloudsoft.io>
AuthorDate: Fri Jul 16 15:34:05 2021 +0100
Changed attributes to a MutableMap
---
.../brooklyn/core/mgmt/entitlement/WebEntitlementContext.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/entitlement/WebEntitlementContext.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/entitlement/WebEntitlementContext.java
index e1e83ce..a7673ae 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/entitlement/WebEntitlementContext.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/entitlement/WebEntitlementContext.java
@@ -19,6 +19,7 @@
package org.apache.brooklyn.core.mgmt.entitlement;
import org.apache.brooklyn.api.mgmt.entitlement.EntitlementContext;
+import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.javalang.JavaClassNames;
import java.util.HashMap;
@@ -38,7 +39,7 @@ public class WebEntitlementContext implements EntitlementContext {
final String user;
final String sourceIp;
final String requestUri;
- final Map<String, Object> attributes;
+ final Map<String, Object> attributes = MutableMap.of();
/**
* A mostly-unique identifier for the inbound request, to distinguish
@@ -47,7 +48,7 @@ public class WebEntitlementContext implements EntitlementContext {
final String requestUniqueIdentifier;
public WebEntitlementContext(String user, String sourceIp, String requestUri, String requestUniqueIdentifier) {
- this(user, sourceIp, requestUri, requestUniqueIdentifier, new HashMap<>());
+ this(user, sourceIp, requestUri, requestUniqueIdentifier, null);
}
public WebEntitlementContext(String user, String sourceIp, String requestUri, String requestUniqueIdentifier, Map<String, Object> attributes) {
@@ -56,9 +57,7 @@ public class WebEntitlementContext implements EntitlementContext {
this.requestUri = requestUri;
this.requestUniqueIdentifier = requestUniqueIdentifier;
if(attributes!=null)
- this.attributes = attributes;
- else
- this.attributes = new HashMap<>();
+ this.attributes.putAll(attributes) ;
}
@Override public String user() { return user; }
[brooklyn-server] 03/03: This closes #1202
Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit 0ab9098f70f8ea30f244c3862713d7a265439420
Merge: 0bab702 48c962a
Author: Alex Heneveld <al...@cloudsoftcorp.com>
AuthorDate: Fri Jul 16 23:10:30 2021 +0100
This closes #1202
.../mgmt/entitlement/WebEntitlementContext.java | 16 ++++-
.../apache/brooklyn/rest/BrooklynWebConfig.java | 5 ++
.../rest/filter/EntitlementContextFilter.java | 33 ++++++---
.../security/provider/LdapSecurityProvider.java | 84 ++++++++++++++++++++--
4 files changed, 119 insertions(+), 19 deletions(-)