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

Allow reverse tunnel join without exposing the web API #13598

Merged
merged 43 commits into from
Aug 15, 2022

Conversation

atburke
Copy link
Contributor

@atburke atburke commented Jun 16, 2022

This PR allows agents to join over a reverse tunnel (port 3024 by default) only, instead of also requiring access to the web API (port 3080). This is accomplished by multiplexing a small subset of the web API (specifically, /webapi/find and /webapi/host/credentials) over port 3024 when the web API and reverse tunnel aren't already being multiplexed.

Resolves #12730.

Copy link
Contributor

@strideynet strideynet left a comment

Choose a reason for hiding this comment

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

Looks good.

lib/web/apiserver.go Outdated Show resolved Hide resolved
@zmb3 zmb3 changed the title Allow agent joining over reverse tunnel Allow reverse tunnel join without exposing the web API Jun 17, 2022
Copy link
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me.

I'm not super familiar with the init functions and the complexity over at some funcs, like setupProxyListeners, is pretty high (not that this is your fault!). Because of that I think we should ask someone like @r0mant to take a look as well.

Apologies for the delay 🙏

lib/service/service.go Outdated Show resolved Hide resolved
lib/service/service.go Outdated Show resolved Hide resolved
lib/service/service.go Outdated Show resolved Hide resolved
lib/web/apiserver.go Outdated Show resolved Hide resolved
docs/pages/setup/admin/adding-nodes.mdx Outdated Show resolved Hide resolved
lib/web/apiserver.go Outdated Show resolved Hide resolved
lib/web/apiserver.go Show resolved Hide resolved
lib/web/apiserver.go Outdated Show resolved Hide resolved
integration/integration_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

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

LGTM, barring that one small comment.

lib/service/service.go Outdated Show resolved Hide resolved
@atburke
Copy link
Contributor Author

atburke commented Jun 28, 2022

@ptgott Mind looking at the docs again when you have a moment?

@jakule jakule requested a review from ptgott June 30, 2022 17:03
docs/pages/setup/admin/adding-nodes.mdx Outdated Show resolved Hide resolved
docs/pages/setup/admin/adding-nodes.mdx Outdated Show resolved Hide resolved
Service through the Proxy.
to talk to port `3024` on the Proxy Service, which is used to both fetch the
credentials (SSH and TLS certificates) and establish a connection to the Auth
Service through the Proxy. Alternatively, port `3080` can be used to fetch
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, if there's no difference between using port 3024 and 3080, we could probably remove the last sentence of this paragraph and say, "...the Node needs to be able to talk to either port 3024 or 3080 on the Proxy Service...".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

3024 is used in both cases to establish the reverse tunnel connection; it's just a question of whether the node fetches credentials over 3024 or 3080. It would have to be something like "either port 3024 or 3024 AND 3080", and I'm not sure how to word that elegantly.

Copy link
Contributor

Choose a reason for hiding this comment

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

How does the new behavior work with TLS multiplexing? This paragraph (and the ones after it) seem to assume that TLS multiplexing is disabled by default, while in all supported Teleport versions now (v8 and above), this is not the case.

In any case, I think this paragraph would be much clearer by:

  • Replacing specific port numbers with references to Proxy Service configuration settings. Otherwise, the text gets a bit muddled, since we have to go back and forth between port numbers and their usage. If readers need to know the exact ports to use, we could include a command to hit the /webapi/ping endpoint.

  • Rephrasing "can be used" in the last sentence of the paragraph to something more specific. I'm not sure if 3080 only needs to be open on the Proxy Service or if there's some specific config setting/flag/env variable the user needs to change from something else to 3080.

@github-actions
Copy link

@atburke - this PR is large and will require admin approval to merge. Consider breaking it up into a series smaller changes.

@atburke
Copy link
Contributor Author

atburke commented Jul 28, 2022

@codingllama @strideynet I've fixed the last bugs. Feel free to make another review pass when you can.

Copy link
Contributor

@strideynet strideynet left a comment

Choose a reason for hiding this comment

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

Just a few thoughts, once these are addressed/discussed I'll approve.

lib/multiplexer/multiplexer.go Show resolved Hide resolved
lib/service/service.go Outdated Show resolved Hide resolved
lib/web/apiserver.go Outdated Show resolved Hide resolved
@atburke
Copy link
Contributor Author

atburke commented Aug 11, 2022

@codingllama @strideynet Can I get a review on this?

Copy link
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

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

@atburke, please sync with master and solve the conflicts.

lib/service/service.go Outdated Show resolved Hide resolved
lib/multiplexer/multiplexer.go Show resolved Hide resolved
integration/integration_test.go Outdated Show resolved Hide resolved
integration/integration_test.go Outdated Show resolved Hide resolved
integration/integration_test.go Outdated Show resolved Hide resolved
lib/service/service.go Outdated Show resolved Hide resolved
lib/service/service.go Show resolved Hide resolved
lib/service/service.go Show resolved Hide resolved
lib/web/apiserver.go Show resolved Hide resolved
lib/web/apiserver.go Show resolved Hide resolved
Copy link
Contributor

@strideynet strideynet left a comment

Choose a reason for hiding this comment

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

I'm happy to approve this as the majority of this looks good, would be nice to iron out a decision on returning vs warning on errors for the listeners/muxers though. I think that we probably aren't handling this very well in the existing codebase so it might be nice to make a decision and then apply it retrospectively to all the handlers in another PR.

Copy link
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

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

Please address the remaining comment, otherwise LGTM.

lib/multiplexer/multiplexer_test.go Show resolved Hide resolved
lib/reversetunnel/agentpool.go Outdated Show resolved Hide resolved
lib/reversetunnel/agentpool.go Outdated Show resolved Hide resolved
@atburke atburke enabled auto-merge (squash) August 15, 2022 20:38
@atburke atburke merged commit 9607fdd into master Aug 15, 2022
@github-actions
Copy link

@atburke See the table below for backport results.

Branch Result
branch/v10 Failed

logand22 pushed a commit that referenced this pull request Aug 19, 2022
This change allows agents to join over a reverse tunnel (port 3024 by default) only, instead of also requiring access to the web API (port 3080).
@zmb3 zmb3 deleted the atburke/reverse-tunnel-agent-join branch September 9, 2022 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow agent joining over port 3024
4 participants