chore: Add workspaceId to the redirect url for auth datasource flow (#30463)
## Description > Add a TL;DR when description is extra long (helps content team) > > Please include a summary of the changes and which issue has been fixed. Please also include relevant motivation > and context. List any dependencies that are required for this change > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Integrated workspace identification into authentication services for enhanced multi-workspace support. - **Refactor** - Improved internal handling of workspace-specific data during authentication processes. - **Tests** - Updated tests to include workspace identification checks in authentication scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: “sneha122” <“sneha@appsmith.com”>
This commit is contained in:
parent
38d37ba874
commit
80d5c2baf6
|
|
@ -18,6 +18,8 @@ public class IntegrationDTO {
|
|||
|
||||
String datasourceId;
|
||||
|
||||
String workspaceId;
|
||||
|
||||
String applicationId;
|
||||
|
||||
String pageId;
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE {
|
|||
.flatMap(datasource -> datasourceService.getTrueEnvironmentId(
|
||||
datasource.getWorkspaceId(), environmentId, datasource.getPluginId(), null))
|
||||
.cache();
|
||||
Mono<String> workspaceIdMono = datasourceMonoCached.map(Datasource::getWorkspaceId);
|
||||
|
||||
return datasourceMonoCached
|
||||
.zipWith(trueEnvironmentIdCached)
|
||||
|
|
@ -127,16 +128,18 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE {
|
|||
.switchIfEmpty(Mono.error(
|
||||
new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.DATASOURCE, datasourceId)))
|
||||
.flatMap(this::validateRequiredFieldsForGenericOAuth2)
|
||||
.zipWith(trueEnvironmentIdCached)
|
||||
.zipWith(Mono.zip(workspaceIdMono, trueEnvironmentIdCached))
|
||||
.flatMap(tuple2 -> {
|
||||
DatasourceStorage datasourceStorage = tuple2.getT1();
|
||||
String trueEnvironmentId = tuple2.getT2();
|
||||
String workspaceId = tuple2.getT2().getT1();
|
||||
String trueEnvironmentId = tuple2.getT2().getT2();
|
||||
OAuth2 oAuth2 = (OAuth2)
|
||||
datasourceStorage.getDatasourceConfiguration().getAuthentication();
|
||||
final String redirectUri = redirectHelper.getRedirectDomain(httpRequest.getHeaders());
|
||||
final String state = StringUtils.hasText(branchName)
|
||||
? String.join(",", pageId, datasourceId, trueEnvironmentId, redirectUri, branchName)
|
||||
: String.join(",", pageId, datasourceId, trueEnvironmentId, redirectUri);
|
||||
? String.join(
|
||||
",", pageId, datasourceId, trueEnvironmentId, redirectUri, workspaceId, branchName)
|
||||
: String.join(",", pageId, datasourceId, trueEnvironmentId, redirectUri, workspaceId);
|
||||
// Adding basic uri components
|
||||
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(
|
||||
oAuth2.getAuthorizationUrl())
|
||||
|
|
@ -332,7 +335,8 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE {
|
|||
final String datasourceId = splitState[1];
|
||||
final String environmentId = splitState[2];
|
||||
final String redirectOrigin = splitState[3];
|
||||
final String branchName = splitState.length == 5 ? splitState[4] : null;
|
||||
final String workspaceId = splitState[4];
|
||||
final String branchName = splitState.length == 6 ? splitState[5] : null;
|
||||
String response = SUCCESS;
|
||||
if (error != null) {
|
||||
response = error;
|
||||
|
|
@ -350,6 +354,7 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE {
|
|||
+ "?response_status="
|
||||
+ responseStatus
|
||||
+ "&view_mode=true"
|
||||
+ (StringUtils.hasText(workspaceId) ? "&workspaceId=" + workspaceId : "")
|
||||
+ (StringUtils.hasText(branchName) ? "&branch=" + branchName : ""))
|
||||
.onErrorResume(e -> Mono.just(redirectOrigin + Entity.SLASH + Entity.APPLICATIONS
|
||||
+ "?response_status="
|
||||
|
|
@ -415,6 +420,7 @@ public class AuthenticationServiceCEImpl implements AuthenticationServiceCE {
|
|||
integrationDTO.setApplicationId(defaultApplicationId);
|
||||
integrationDTO.setBranch(branchName);
|
||||
integrationDTO.setImportForGit(importForGit);
|
||||
integrationDTO.setWorkspaceId(datasource.getWorkspaceId());
|
||||
final Plugin plugin = tuple.getT3();
|
||||
integrationDTO.setPluginName(plugin.getPluginName());
|
||||
integrationDTO.setPluginVersion(plugin.getVersion());
|
||||
|
|
|
|||
|
|
@ -242,7 +242,8 @@ public class AuthenticationServiceTest {
|
|||
pageDto.getId(),
|
||||
datasourceId1,
|
||||
defaultEnvironmentId,
|
||||
"https://mock.origin.com")
|
||||
"https://mock.origin.com",
|
||||
workspace.getId())
|
||||
+ "&scope=Scope\\d%20Scope\\d"
|
||||
+ "&key=value"));
|
||||
})
|
||||
|
|
@ -336,6 +337,7 @@ public class AuthenticationServiceTest {
|
|||
datasourceId,
|
||||
defaultEnvironmentId,
|
||||
"https://mock.origin.com",
|
||||
workspaceId,
|
||||
"testBranch")
|
||||
+ "&scope=Scope\\d%20Scope\\d"
|
||||
+ "&key=value"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user