-
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
Changes from 3 commits
e308fa5
fddecc4
c2e5c0f
bda6b9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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,10 @@ | |||||
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 java.text.ParseException; | ||||||
import java.util.Arrays; | ||||||
import java.util.Map; | ||||||
import java.util.Optional; | ||||||
|
||||||
|
@@ -173,8 +176,21 @@ protected AuthenticationResult doAuthenticate(MessageContext messageContext) { | |||||
ServiceProvider serviceProvider = null; | ||||||
String serviceProviderName = null; | ||||||
String serviceProviderUUID = null; | ||||||
String accessingTenantDomain = 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) { | ||||||
accessingTenantDomain = authorizedUser.getTenantDomain(); | ||||||
serviceProvider = OAuth2Util.getServiceProvider( | ||||||
oAuth2IntrospectionResponseDTO.getClientId(), accessingTenantDomain); | ||||||
boolean isSharedApp = Arrays.stream(serviceProvider.getSpProperties()).anyMatch( | ||||||
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.
Suggested change
|
||||||
property -> "isAppShared".equals(property.getName()) && | ||||||
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. isAppShared - > Use a contant 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. Use the existing contant |
||||||
Boolean.parseBoolean(property.getValue())); | ||||||
authenticationContext.addParameter("isAppShared", isSharedApp); | ||||||
} else { | ||||||
serviceProvider = OAuth2Util.getServiceProvider(oAuth2IntrospectionResponseDTO.getClientId()); | ||||||
} | ||||||
if (serviceProvider != null) { | ||||||
serviceProviderName = serviceProvider.getApplicationName(); | ||||||
serviceProviderUUID = serviceProvider.getApplicationResourceId(); | ||||||
|
@@ -193,8 +209,14 @@ protected AuthenticationResult doAuthenticate(MessageContext messageContext) { | |||||
|
||||||
String serviceProviderTenantDomain = null; | ||||||
try { | ||||||
serviceProviderTenantDomain = | ||||||
OAuth2Util.getTenantDomainOfOauthApp(oAuth2IntrospectionResponseDTO.getClientId()); | ||||||
if (StringUtils.isNotEmpty(accessingTenantDomain)) { | ||||||
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(), | ||||||
accessingTenantDomain); | ||||||
} 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: " | ||||||
|
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.
applicationResidentTenantDomain