usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [34/50] [abbrv] usergrid git commit: Expose external SSO userid and reduce the management/me response.
Date Wed, 17 Aug 2016 21:17:53 GMT
Expose external SSO userid and reduce the management/me response.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/69625af0
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/69625af0
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/69625af0

Branch: refs/heads/datastax-cass-driver
Commit: 69625af052152d4157f4477302adb5231f2fa471
Parents: 0b84023
Author: Michael Russo <mrusso@apigee.com>
Authored: Tue Aug 2 11:24:49 2016 -0700
Committer: Michael Russo <mrusso@apigee.com>
Committed: Tue Aug 2 11:24:49 2016 -0700

----------------------------------------------------------------------
 .../usergrid/rest/management/ManagementResource.java   |  7 +++----
 .../usergrid/rest/management/users/UserResource.java   |  3 +--
 .../apache/usergrid/management/ManagementService.java  |  2 +-
 .../management/cassandra/ManagementServiceImpl.java    | 13 +++++++------
 .../usergrid/security/sso/ApigeeSSO2Provider.java      |  1 +
 5 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/69625af0/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
index 83f06ed..9ef67c9 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/ManagementResource.java
@@ -61,8 +61,6 @@ import java.util.Map;
 import static javax.servlet.http.HttpServletResponse.*;
 import static javax.ws.rs.core.MediaType.*;
 import static org.apache.commons.lang.StringUtils.isNotBlank;
-import static org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl.USERGRID_EXTERNAL_SSO_PROVIDER;
-import static org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl.USERGRID_EXTERNAL_SSO_PROVIDER_URL;
 import static org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl.USERGRID_EXTERNAL_SSO_ENABLED;
 import static org.apache.usergrid.utils.JsonUtils.mapToJsonString;
 import static org.apache.usergrid.utils.StringUtils.stringOrSubstringAfterFirst;
@@ -222,7 +220,8 @@ public class ManagementResource extends AbstractContextResource {
             access_info.setProperty("external_sso_user_id", ssoUserId);
         }
 
-        access_info.setProperty( "user", management.getAdminUserOrganizationData( user, true
) );
+        access_info.setProperty( "user", management.getAdminUserOrganizationData( user, true,
false) );
+
 
         return Response.status( SC_OK ).type( jsonMediaType( callback ) )
             .entity( wrapWithCallback( access_info, callback ) ).build();
@@ -413,7 +412,7 @@ public class ManagementResource extends AbstractContextResource {
                     new AccessInfo().withExpiresIn( tokens.getMaxTokenAgeInSeconds( token
) ).withAccessToken( token )
                                     .withPasswordChanged( passwordChanged );
 
-            access_info.setProperty( "user", management.getAdminUserOrganizationData( user,
me ) );
+            access_info.setProperty( "user", management.getAdminUserOrganizationData( user,
true, false) );
 
             // increment counters for admin login
             management.countAdminUserAction( user, "login" );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/69625af0/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
index e511e2e..0e89294 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/users/UserResource.java
@@ -47,7 +47,6 @@ import java.util.Map;
 import java.util.UUID;
 
 import static org.apache.usergrid.security.shiro.utils.SubjectUtils.isServiceAdmin;
-import static org.apache.usergrid.security.tokens.cassandra.TokenServiceImpl.USERGRID_EXTERNAL_SSO_PROVIDER_URL;
 import static org.apache.usergrid.utils.ConversionUtils.string;
 
 
@@ -209,7 +208,7 @@ public class UserResource extends AbstractContextResource {
         // commenting out creation of token each time and setting the token value to the
one sent in the request.
         // String token = management.getAccessTokenForAdminUser( user.getUuid(), ttl );
 
-        Map<String, Object> userOrganizationData = management.getAdminUserOrganizationData(
user, !shallow );
+        Map<String, Object> userOrganizationData = management.getAdminUserOrganizationData(
user, !shallow, !shallow);
         //userOrganizationData.put( "token", token );
         response.setData( userOrganizationData );
         response.setSuccess();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/69625af0/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
b/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
index 1d74ec3..a161a27 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/ManagementService.java
@@ -157,7 +157,7 @@ public interface ManagementService {
 
 	UserInfo getAdminUserInfoFromAccessToken( String token ) throws Exception;
 
-	Map<String, Object> getAdminUserOrganizationData( UserInfo user, boolean deep ) throws
Exception;
+	Map<String, Object> getAdminUserOrganizationData(UserInfo user, boolean includeApps,
boolean includeOrgUsers) throws Exception;
 
 	Map<String, Object> getAdminUserOrganizationData( UUID userId ) throws Exception;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/69625af0/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
index 746d9dd..903c200 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/cassandra/ManagementServiceImpl.java
@@ -1635,7 +1635,7 @@ public class ManagementServiceImpl implements ManagementService {
     @Override
     public Map<String, Object> getAdminUserOrganizationData( UUID userId ) throws Exception
{
         UserInfo user = getAdminUserByUuid( userId );
-        return getAdminUserOrganizationData( user, true );
+        return getAdminUserOrganizationData( user, true, true);
     }
 
 
@@ -1647,7 +1647,7 @@ public class ManagementServiceImpl implements ManagementService {
 
 
     @Override
-    public Map<String, Object> getAdminUserOrganizationData( UserInfo user, boolean
deep ) throws Exception {
+    public Map<String, Object> getAdminUserOrganizationData(UserInfo user, boolean
includeApps, boolean includeOrgUsers) throws Exception {
 
         Map<String, Object> json = new HashMap<>();
 
@@ -1676,10 +1676,11 @@ public class ManagementServiceImpl implements ManagementService {
             jsonOrganization.put( PROPERTY_UUID, organization.getKey() );
             jsonOrganization.put( "properties", getOrganizationByUuid( organization.getKey()
).getProperties() );
 
-            if ( deep ) {
-                BiMap<UUID, String> applications = getApplicationsForOrganization(
organization.getKey() );
-                jsonOrganization.put( "applications", applications.inverse() );
-
+            if ( includeApps ) {
+                BiMap<UUID, String> applications = getApplicationsForOrganization(organization.getKey());
+                jsonOrganization.put("applications", applications.inverse());
+            }
+            if ( includeOrgUsers ){
                 List<UserInfo> users = getAdminUsersForOrganization( organization.getKey()
);
                 Map<String, Object> jsonUsers = new HashMap<>();
                 for ( UserInfo u : users ) {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/69625af0/stack/services/src/main/java/org/apache/usergrid/security/sso/ApigeeSSO2Provider.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/sso/ApigeeSSO2Provider.java
b/stack/services/src/main/java/org/apache/usergrid/security/sso/ApigeeSSO2Provider.java
index d48495d..0165e1d 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/sso/ApigeeSSO2Provider.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/sso/ApigeeSSO2Provider.java
@@ -127,6 +127,7 @@ public class ApigeeSSO2Provider implements ExternalSSOProvider {
         tokenDetails.put("username", (String)claims.get("user_name"));
         tokenDetails.put("email", (String)claims.get("email"));
         tokenDetails.put("expiry", claims.get("exp").toString());
+        tokenDetails.put("user_id", claims.get("user_id").toString());
 
 
         return tokenDetails;


Mime
View raw message