Skip to content
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

Conversation

ShanChathusanda93
Copy link
Contributor

@ShanChathusanda93 ShanChathusanda93 commented Nov 1, 2024

Proposed changes in this pull request

<OrgContextsToRewriteInTenantPerspective>
    <WebApp>
        <Context>
            <BasePath>/api/</BasePath>
            <SubPaths>
                <Path>/api/identity/oauth2/dcr/</Path>
            </SubPaths>
        </Context>
        <Context>
            <BasePath>/oauth2/</BasePath>
            <SubPaths>
                <Path>/oauth2/token</Path>
                <Path>/oauth2/introspect</Path>
            </SubPaths>
        </Context>
    </WebApp>
</OrgContextsToRewriteInTenantPerspective>
  • DCR endpoint will create the OAuth2 applications in the sub organization level
    • Path : /t/{tenant-domain}/o/{org-id}/api/identity/oauth2/dcr/v1.1/register
  • Token generation and introspection
    • Path : /t/{tenant-domain}/o/{org-id}/oauth2/token?scope=openid ...
  • When access tokens are handled the tokens will be handled from the sub organization level by checking the type of the application which are using the token service.

When should this PR be merged

pom.xml Outdated
@@ -385,8 +385,8 @@
<osgi.util.tracker.imp.pkg.version.range>[1.5.1, 2.0.0)</osgi.util.tracker.imp.pkg.version.range>

<!-- Carbon Kernel version -->
<carbon.kernel.version>4.9.17</carbon.kernel.version>
<carbon.kernel.feature.version>4.9.0</carbon.kernel.feature.version>
<carbon.kernel.version>4.10.24</carbon.kernel.version>
Copy link
Contributor Author

@ShanChathusanda93 ShanChathusanda93 Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update this with the new release version with the changes in wso2/carbon-kernel#4104

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to the latest kernel release 4.10.26[1]

[1] https://github.com/wso2/carbon-kernel/tree/v4.10.26

@ShanChathusanda93 ShanChathusanda93 force-pushed the tenant-perspective-org-access-branch branch from 693f0cf to 85ded2d Compare November 27, 2024 05:17
@ShanChathusanda93 ShanChathusanda93 force-pushed the tenant-perspective-org-access-branch branch 2 times, most recently from 7b7ab3b to 095707b Compare December 1, 2024 08:38
@ShanChathusanda93 ShanChathusanda93 force-pushed the tenant-perspective-org-access-branch branch from 095707b to fddecc4 Compare December 1, 2024 18:58
@@ -173,8 +176,21 @@ protected AuthenticationResult doAuthenticate(MessageContext messageContext) {
ServiceProvider serviceProvider = null;
String serviceProviderName = null;
String serviceProviderUUID = null;
String accessingTenantDomain = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applicationResidentTenantDomain

serviceProvider = OAuth2Util.getServiceProvider(
oAuth2IntrospectionResponseDTO.getClientId(), accessingTenantDomain);
boolean isSharedApp = Arrays.stream(serviceProvider.getSpProperties()).anyMatch(
property -> "isAppShared".equals(property.getName()) &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isAppShared - > Use a contant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the existing contant

accessingTenantDomain = authorizedUser.getTenantDomain();
serviceProvider = OAuth2Util.getServiceProvider(
oAuth2IntrospectionResponseDTO.getClientId(), accessingTenantDomain);
boolean isSharedApp = Arrays.stream(serviceProvider.getSpProperties()).anyMatch(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
boolean isSharedApp = Arrays.stream(serviceProvider.getSpProperties()).anyMatch(
boolean isB2BSharedApp = Arrays.stream(serviceProvider.getSpProperties()).anyMatch(

serviceProviderTenantDomain =
OAuth2Util.getTenantDomainOfOauthApp(oAuth2IntrospectionResponseDTO.getClientId());
if (StringUtils.isNotEmpty(accessingTenantDomain)) {
serviceProviderTenantDomain =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the method because we are extracting the tenant domain from above

@ShanChathusanda93
Copy link
Contributor Author

Closing this PR since the PR is devided to two parts [1][2]

[1] #298
[2] Will be updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants