Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Expose external SSO userid and reduce the management/me response.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Russo committed Aug 2, 2016
1 parent 0b84023 commit 69625af
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
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;
Expand Down Expand Up @@ -222,7 +220,8 @@ public Response getAccessTokenLight( @Context UriInfo ui, @HeaderParam( "Authori
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();
Expand Down Expand Up @@ -413,7 +412,7 @@ else if ( "client_credentials".equals( grant_type ) ) {
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" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
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;


Expand Down Expand Up @@ -209,7 +208,7 @@ public ApiResponse getUserData( @Context UriInfo ui, @QueryParam( "ttl" ) long t
// 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ OrganizationOwnerInfo createOwnerAndOrganization( String organizationName, Strin

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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,7 @@ public BiMap<UUID, String> getOrganizationsForAdminUser( UUID userId ) throws Ex
@Override
public Map<String, Object> getAdminUserOrganizationData( UUID userId ) throws Exception {
UserInfo user = getAdminUserByUuid( userId );
return getAdminUserOrganizationData( user, true );
return getAdminUserOrganizationData( user, true, true);
}


Expand All @@ -1647,7 +1647,7 @@ public Long getLastAdminPasswordChange( UUID userId ) throws Exception {


@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<>();

Expand Down Expand Up @@ -1676,10 +1676,11 @@ public Map<String, Object> getAdminUserOrganizationData( UserInfo user, boolean
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 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public Map<String, String> getDecodedTokenDetails(String token) throws Exception
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;
Expand Down

0 comments on commit 69625af

Please sign in to comment.