-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to access organization resources in tenant perspective #295
Closed
ShanChathusanda93
wants to merge
4
commits into
wso2-extensions:master
from
ShanChathusanda93:tenant-perspective-org-access-branch
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e308fa5
Add support to access organization resources in tenant perspective
ShanChathusanda93 fddecc4
Remove sub org app check from authz and token handlers
ShanChathusanda93 c2e5c0f
Update dependency versions
ShanChathusanda93 bda6b9f
Improve token handler
ShanChathusanda93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
import org.wso2.carbon.identity.auth.service.AuthenticationResult; | ||
import org.wso2.carbon.identity.auth.service.AuthenticationStatus; | ||
import org.wso2.carbon.identity.auth.service.handler.AuthenticationHandler; | ||
import org.wso2.carbon.identity.auth.service.internal.AuthenticationServiceHolder; | ||
import org.wso2.carbon.identity.auth.service.util.AuthConfigurationUtil; | ||
import org.wso2.carbon.identity.auth.service.util.Constants; | ||
import org.wso2.carbon.identity.core.bean.context.MessageContext; | ||
|
@@ -55,8 +56,11 @@ | |
import org.wso2.carbon.identity.oauth2.token.bindings.TokenBinding; | ||
import org.wso2.carbon.identity.oauth2.util.OAuth2Util; | ||
import org.wso2.carbon.identity.oauth2.validators.RefreshTokenValidator; | ||
import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException; | ||
import org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants; | ||
|
||
import java.text.ParseException; | ||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
|
@@ -173,8 +177,21 @@ protected AuthenticationResult doAuthenticate(MessageContext messageContext) { | |
ServiceProvider serviceProvider = null; | ||
String serviceProviderName = null; | ||
String serviceProviderUUID = null; | ||
String applicationResidentTenantDomain = null; | ||
try { | ||
serviceProvider = OAuth2Util.getServiceProvider(oAuth2IntrospectionResponseDTO.getClientId()); | ||
// Getting the accessing tenant domain from the authenticated user through the introspection | ||
// response where the token is introspected. | ||
if (authorizedUser != null) { | ||
applicationResidentTenantDomain = authorizedUser.getTenantDomain(); | ||
serviceProvider = OAuth2Util.getServiceProvider( | ||
oAuth2IntrospectionResponseDTO.getClientId(), applicationResidentTenantDomain); | ||
boolean isB2BSharedApp = Arrays.stream(serviceProvider.getSpProperties()).anyMatch( | ||
property -> "isAppShared".equals(property.getName()) && | ||
Boolean.parseBoolean(property.getValue())); | ||
authenticationContext.addParameter("isB2BAppShared", isB2BSharedApp); | ||
} else { | ||
serviceProvider = OAuth2Util.getServiceProvider(oAuth2IntrospectionResponseDTO.getClientId()); | ||
} | ||
if (serviceProvider != null) { | ||
serviceProviderName = serviceProvider.getApplicationName(); | ||
serviceProviderUUID = serviceProvider.getApplicationResourceId(); | ||
|
@@ -193,8 +210,14 @@ protected AuthenticationResult doAuthenticate(MessageContext messageContext) { | |
|
||
String serviceProviderTenantDomain = null; | ||
try { | ||
serviceProviderTenantDomain = | ||
OAuth2Util.getTenantDomainOfOauthApp(oAuth2IntrospectionResponseDTO.getClientId()); | ||
if (StringUtils.isNotEmpty(applicationResidentTenantDomain)) { | ||
serviceProviderTenantDomain = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the method because we are extracting the tenant domain from above |
||
OAuth2Util.getTenantDomainOfOauthApp(oAuth2IntrospectionResponseDTO.getClientId(), | ||
applicationResidentTenantDomain); | ||
} else { | ||
serviceProviderTenantDomain = | ||
OAuth2Util.getTenantDomainOfOauthApp(oAuth2IntrospectionResponseDTO.getClientId()); | ||
} | ||
} catch (InvalidOAuthClientException | IdentityOAuth2Exception e) { | ||
if (log.isDebugEnabled()) { | ||
log.debug("Error occurred while getting the OAuth App tenantDomain by Consumer key: " | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isAppShared - > Use a contant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the existing contant