Skip to content

[ws-proxy] close connection if workspace or port stopped share #20248

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

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

iQQBot
Copy link
Contributor

@iQQBot iQQBot commented Sep 27, 2024

Description

This PR adds a mechanism to disconnect previously unauthenticated connections if the visibility of the workspace or port changes.

Related Issue(s)

Fixes ENT-755

How to test

  1. start a workspace
  2. execute example stream server
  3. make port public
  4. try using curl https://workspace-port-url/hello and open this URL in browser (with login)
  5. try to make port private
  6. you will observe the curl command will disconnection immediately and browser one is still work.
const express = require('express');
const app = express();

const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

app.get('/hello', async (req, res) => {
    res.write('hello');
    while (true) {
        await sleep(1000);
        res.write('\nhello' + new Date());
    }
})

app.listen(3000, () => {})

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • /werft preemptible
    Saves cost. Untick this only if you're really sure you need a non-preemtible machine.
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold


authenticated, err := authenticate()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we will do authenticate first, if user already authenticated we don't have to add context for this connection.

Copy link
Member

@filiptronicek filiptronicek left a comment

Choose a reason for hiding this comment

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

Works exactly as expected and code looks great. Thank you!

@roboquat roboquat merged commit 9e0f6e1 into main Sep 27, 2024
14 of 16 checks passed
@roboquat roboquat deleted the pd/ent-755 branch September 27, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants