Skip to content

Commit

Permalink
Looks like it isn't used at all 🤔
Browse files Browse the repository at this point in the history
  • Loading branch information
sharat87 committed Nov 24, 2024
1 parent 06cc4b7 commit 8b21083
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 49 deletions.
2 changes: 0 additions & 2 deletions app/client/src/api/CloudServicesApi.ts

This file was deleted.

36 changes: 7 additions & 29 deletions app/client/src/sagas/DatasourcesSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ import { getFormData } from "selectors/formSelectors";
import { getCurrentWorkspaceId } from "ee/selectors/selectedWorkspaceSelectors";
import { getConfigInitialValues } from "components/formControls/utils";
import { setActionProperty } from "actions/pluginActionActions";
import { authorizeDatasourceWithAppsmithToken } from "api/CloudServicesApi";
import {
createMessage,
DATASOURCE_CREATE,
Expand Down Expand Up @@ -711,9 +710,7 @@ function* redirectAuthorizationCodeSaga(
pluginType: PluginType;
}>,
) {
const { contextId, contextType, datasourceId, pluginType } =
actionPayload.payload;
const isImport: string = yield select(getWorkspaceIdForImport);
const { contextId, datasourceId, pluginType } = actionPayload.payload;
const branchName: string | undefined = yield select(getCurrentGitBranch);

if (pluginType === PluginType.API) {
Expand All @@ -728,31 +725,12 @@ function* redirectAuthorizationCodeSaga(

window.location.href = windowLocation;
} else {
try {
// Get an "appsmith token" from the server
const response: ApiResponse<string> = yield OAuthApi.getAppsmithToken(
datasourceId,
contextId,
contextType,
!!isImport,
);

if (validateResponse(response)) {
const appsmithToken = response.data;

// Save the token for later use once we come back from the auth flow
localStorage.setItem(APPSMITH_TOKEN_STORAGE_KEY, appsmithToken);
// Redirect to the cloud services to authorise
window.location.assign(
authorizeDatasourceWithAppsmithToken(appsmithToken),
);
}
} catch (e) {
toast.show(OAUTH_AUTHORIZATION_FAILED, {
kind: "error",
});
log.error(e);
}
toast.show(OAUTH_AUTHORIZATION_FAILED, {
kind: "error",
});
log.error(
new Error("Can't redirect for authorization for non-API datasource"),
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

import com.appsmith.external.models.OAuth2ResponseDTO;
import com.appsmith.external.views.Views;
import com.appsmith.server.configurations.CloudServicesConfig;
import com.appsmith.server.constants.FieldName;
import com.appsmith.server.constants.Url;
import com.appsmith.server.dtos.RequestAppsmithTokenDTO;
import com.appsmith.server.dtos.ResponseDTO;
import com.appsmith.server.solutions.AuthenticationService;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -25,12 +22,14 @@

@Slf4j
@RequestMapping(Url.SAAS_URL)
@RequiredArgsConstructor
public class SaasControllerCE {

private final AuthenticationService authenticationService;

private final CloudServicesConfig cloudServicesConfig;
@Autowired
public SaasControllerCE(AuthenticationService authenticationService) {
this.authenticationService = authenticationService;
}

@JsonView(Views.Public.class)
@PostMapping("/{datasourceId}/oauth")
Expand Down Expand Up @@ -64,16 +63,4 @@ public Mono<ResponseDTO<OAuth2ResponseDTO>> getAccessToken(
.getAccessTokenFromCloud(datasourceId, environmentId, appsmithToken)
.map(datasource -> new ResponseDTO<>(HttpStatus.OK.value(), datasource, null));
}

@GetMapping("authorize")
public Mono<Void> redirectForAuthorize(ServerWebExchange exchange, @RequestParam String appsmithToken) {
final String url = cloudServicesConfig.getBaseUrl() + "/api/v1/integrations/oauth/authorize?appsmithToken="
+ appsmithToken;

ServerHttpResponse response = exchange.getResponse();
response.setStatusCode(HttpStatus.TEMPORARY_REDIRECT);
response.getHeaders().set("Location", url);

return response.writeWith(Mono.just(response.bufferFactory().wrap(new byte[] {})));
}
}

0 comments on commit 8b21083

Please sign in to comment.