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

Adding SSHPortForwarding to RoleOptions proto #49165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eriktate
Copy link
Contributor

@eriktate eriktate commented Nov 18, 2024

This PR is the first for enabling individual access control of both local and remote port forwarding. It adds a SSHPortForwardConfig message which is surfaced through the RoleOptions message on any given role. It also marks PortForwarding as deprecated since we'll want to encourage leveraging SSHPortForwarding going forward. The legacy PortForwarding boolean will still be evaluated and prioritized over SSHPortForwarding for backwards compatibility, which I'll include some more information about in the follow up PR implementing the new config options.

No changelog since this doesn't actually change any functionality and I'll cover the new options in the next PR.

Copy link

🤖 Vercel preview here: https://docs-a38lfwqrd-goteleport.vercel.app/docs/ver/preview

Copy link

🤖 Vercel preview here: https://docs-7zclicyhf-goteleport.vercel.app/docs/ver/preview

Copy link

🤖 Vercel preview here: https://docs-auvan7y8n-goteleport.vercel.app/docs/ver/preview

Copy link

🤖 Vercel preview here: https://docs-bp1o04fn1-goteleport.vercel.app/docs/ver/preview

Copy link

🤖 Vercel preview here: https://docs-3r0agi8kj-goteleport.vercel.app/docs/ver/preview

Copy link

🤖 Vercel preview here: https://docs-58wo7315l-goteleport.vercel.app/docs

Copy link

🤖 Vercel preview here: https://docs-79oiwdi2g-goteleport.vercel.app/docs

Copy link
Contributor

@rosstimothy rosstimothy left a comment

Choose a reason for hiding this comment

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

The rename looks good to me . Please adjust the PR and commit message to reflect the name change though.

Comment on lines 2888 to 2959
// Deprecated: Use SSHPortForwarding instead
BoolValue PortForwarding = 3 [
(gogoproto.nullable) = true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Deprecated: Use SSHPortForwarding instead
BoolValue PortForwarding = 3 [
(gogoproto.nullable) = true,
// Deprecated: Use SSHPortForwarding instead
BoolValue PortForwarding = 3 [
deprecated = true,
(gogoproto.nullable) = true,

// SSHPortForwardConfig defines which types of SSH port forwarding are permitted, if any.
message SSHPortForwardConfig {
// Allow local port forwarding.
BoolValue Local = 1 [
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we anticipate the need to support values beyond true/false? Historically, we've struggled with two-state protos, as we often needed to introduce a third state later, which they couldn't accommodate. Would it make sense to use an enum or string to represent the state instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't any other future restrictions be added to this message? The original Boolean field has been around this long and we haven't had too many regrets or requests to extend functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

They can. it was just to avoid having to deprecate another field and keep supporting it because we never know when/how customers upgrade their clusters.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we would need to deprecate though. Any additional features could be gated by requiring port forwarding is both enabled and is limited by new field foo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm actually combining these bools into a single enum in the implementation, so I could definitely see lifting that into the proto instead. The only thing I don't really like about proto enums is that they're not very nice to work with from the terraform provider since they're effectively magic numbers. That's less of a problem than the schema being inflexible, though

Copy link
Contributor

Choose a reason for hiding this comment

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

If you end up changing to enums, please use plain strings.
Otherwise, we end up with this (as you pointed out)

image

https://goteleport.com/docs/reference/terraform-provider/resources/auth_preference/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After mulling it over some more and talking to TIm, I think leaving them as bools might make for a better user experience. Most of the extensions I can imagine we might want to do would probably involve extending the SSHPortForwardConfig message to contain more fields rather than modifying Local or Remote directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can see this evolving in a way that we would list the allowed ports.
Similar to TCPPorts in the App Resource: #47706

I would prefer something more flexible, but I'm ok with the current design 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose the Local and Remote fields could be messages themselves, which would allow us to do something like:

ssh_port_forwarding:
  local:
    enabled: true
    ports:
      - 8080
  remote:
    enabled: false

It's a little more verbose, but it saves us from having to add top level fields like local_ports and remote_ports later on 🤔 I'll think about this some more, but I might like that better

@eriktate eriktate changed the title Adding PortForwardConfig to RoleOptions proto Adding SSHPortForwarding to RoleOptions proto Nov 21, 2024
Copy link

🤖 Vercel preview here: https://docs-ldyoxe0lf-goteleport.vercel.app/docs

Copy link

🤖 Vercel preview here: https://docs-m36rjw91c-goteleport.vercel.app/docs

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.

4 participants