Fixed EMM-939

merge-requests/7/head
harshanl 9 years ago
parent 5fd9e87dc8
commit 5af6f314d0

@ -81,11 +81,12 @@ public class PermissionBasedScopeValidator extends OAuth2ScopeValidator {
User authzUser = accessTokenDO.getAuthzUser(); User authzUser = accessTokenDO.getAuthzUser();
if ((permission != null) && (authzUser != null)) { if ((permission != null) && (authzUser != null)) {
String username = authzUser.getUserName(); String username = authzUser.getUserName();
String userStore = authzUser.getUserStoreDomain();
int tenantId = OAuthExtUtils.getTenantId(authzUser.getTenantDomain()); int tenantId = OAuthExtUtils.getTenantId(authzUser.getTenantDomain());
UserRealm userRealm = OAuthExtensionsDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId); UserRealm userRealm = OAuthExtensionsDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId);
if (userRealm != null && userRealm.getAuthorizationManager() != null) { if (userRealm != null && userRealm.getAuthorizationManager() != null) {
status = userRealm.getAuthorizationManager() status = userRealm.getAuthorizationManager()
.isUserAuthorized(username, permission.getPath(), .isUserAuthorized(userStore +"/"+ username, permission.getPath(),
PermissionMethod.UI_EXECUTE); PermissionMethod.UI_EXECUTE);
} }
} }

@ -111,6 +111,10 @@ public class OAuthAuthenticator implements WebappAuthenticator {
AuthenticatorFrameworkDataHolder.getInstance().getoAuth2TokenValidationService().validate(dto); AuthenticatorFrameworkDataHolder.getInstance().getoAuth2TokenValidationService().validate(dto);
if (oAuth2TokenValidationResponseDTO.isValid()) { if (oAuth2TokenValidationResponseDTO.isValid()) {
String username = oAuth2TokenValidationResponseDTO.getAuthorizedUser(); String username = oAuth2TokenValidationResponseDTO.getAuthorizedUser();
//Remove the userstore domain from username
if (username.contains("/")) {
username = username.substring(username.indexOf('/') + 1);
}
authenticationInfo.setUsername(username); authenticationInfo.setUsername(username);
authenticationInfo.setTenantDomain(MultitenantUtils.getTenantDomain(username)); authenticationInfo.setTenantDomain(MultitenantUtils.getTenantDomain(username));
authenticationInfo.setTenantId(Utils.getTenantIdOFUser(username)); authenticationInfo.setTenantId(Utils.getTenantIdOFUser(username));

Loading…
Cancel
Save