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

FIX: Add responses for POST Requests in JupyterController #7

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,23 @@ public MetaResponse<InstanceDto> get(@Context final SecurityContext securityCont
@POST
@Path("/{instance}/notebook/open")
@Authenticated
public void jupyterSessionOpen(@Context final SecurityContext securityContext, @PathParam("instance") Instance instance, @NotNull @Valid final JupyterNotebookSessionInput input) {
public MetaResponse<String> jupyterSessionOpen(@Context final SecurityContext securityContext, @PathParam("instance") Instance instance, @NotNull @Valid final JupyterNotebookSessionInput input) {
final User user = this.getUserPrincipal(securityContext);

if (this.instanceService.isAuthorisedForInstance(user, instance)) {
this.instanceJupyterSessionService.create(instance, user, input.getKernelId(), input.getSessionId());
return createResponse();
}

throw new NotFoundException();
}

@POST
@Path("/{instance}/notebook/close")
public void jupyterSessionClose(@PathParam("instance") Instance instance, @NotNull @Valid final JupyterNotebookSessionInput input) {
public MetaResponse<String> jupyterSessionClose(@PathParam("instance") Instance instance, @NotNull @Valid final JupyterNotebookSessionInput input) {
// Allow any access this endpoint: allows the visa-jupyter-proxy to remove zombie sessions without authentication (needs to know both kernelId and sessionId so security risk is low)
this.instanceJupyterSessionService.destroy(instance, input.getKernelId(), input.getSessionId());
return createResponse();
}

private boolean isAuthorisedForJupyter(User user, Instance instance) {
Expand Down
Loading