Skip to content

Commit

Permalink
Merge pull request #7 from matthieuve/main
Browse files Browse the repository at this point in the history
FIX: Add responses for POST Requests in JupyterController
  • Loading branch information
stuartcaunt authored Nov 27, 2024
2 parents 411ccd6 + 0a35830 commit 5fcc1a9
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit 5fcc1a9

Please sign in to comment.