mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'master' of https://github.com/wso2/carbon-device-mgt
This commit is contained in:
commit
72ffe4e4a4
@ -81,11 +81,12 @@ public class PermissionBasedScopeValidator extends OAuth2ScopeValidator {
|
||||
User authzUser = accessTokenDO.getAuthzUser();
|
||||
if ((permission != null) && (authzUser != null)) {
|
||||
String username = authzUser.getUserName();
|
||||
String userStore = authzUser.getUserStoreDomain();
|
||||
int tenantId = OAuthExtUtils.getTenantId(authzUser.getTenantDomain());
|
||||
UserRealm userRealm = OAuthExtensionsDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId);
|
||||
if (userRealm != null && userRealm.getAuthorizationManager() != null) {
|
||||
status = userRealm.getAuthorizationManager()
|
||||
.isUserAuthorized(username, permission.getPath(),
|
||||
.isUserAuthorized(userStore +"/"+ username, permission.getPath(),
|
||||
PermissionMethod.UI_EXECUTE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,6 +111,10 @@ public class OAuthAuthenticator implements WebappAuthenticator {
|
||||
AuthenticatorFrameworkDataHolder.getInstance().getoAuth2TokenValidationService().validate(dto);
|
||||
if (oAuth2TokenValidationResponseDTO.isValid()) {
|
||||
String username = oAuth2TokenValidationResponseDTO.getAuthorizedUser();
|
||||
//Remove the userstore domain from username
|
||||
if (username.contains("/")) {
|
||||
username = username.substring(username.indexOf('/') + 1);
|
||||
}
|
||||
authenticationInfo.setUsername(username);
|
||||
authenticationInfo.setTenantDomain(MultitenantUtils.getTenantDomain(username));
|
||||
authenticationInfo.setTenantId(Utils.getTenantIdOFUser(username));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user