Skip to content

Require identity on tap requests#295

Merged
kleimkuhler merged 9 commits intomasterfrom
kleimkuhler/require-tap-svc-name
Aug 7, 2019
Merged

Require identity on tap requests#295
kleimkuhler merged 9 commits intomasterfrom
kleimkuhler/require-tap-svc-name

Conversation

@kleimkuhler
Copy link
Contributor

@kleimkuhler kleimkuhler commented Aug 1, 2019

Motivation

With linkerd/linkerd2#3155 merging, proxy containers will now always have the LINKERD2_PROXY_TAP_SVC_NAME variable in their environment. This variable can now be reliably used to check that the client names of incoming tap requests match this value.

If the values do not match, we will always return the gRPC Unauthenticated status code. If the values do match, we will accept the connection.

If there is no client identity, we will similarly return the gRPC Unauthenticated status code.

Closes linkerd/linkerd2#3157
Closes linkerd/linkerd2#3163

Signed-off by: Kevin Leimkuhler kleimkuhler@icloud.com

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@kleimkuhler kleimkuhler self-assigned this Aug 1, 2019
Copy link
Member

@adleong adleong left a comment

Choose a reason for hiding this comment

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

If the environment variable is not provided, this will return Unauthenticated on every request? Wouldn't it be better to simply error out at startup time if the variable is missing?

Or, rather, how does this interact with the setting to disable the tap server? I'd expect this behavior:

Tap disabled + No tap svc name => Don't listen on the tap port
Tap disabled + tap svc name => Don't listen on the tap port
Tap enabled + No tap svc name => config error on startup
Tap enabled + tap svc name => listen on tap port and require client name to match

If identity is disabled, then tap must be explicitly disabled.

If ideneity is enabled, then tap can either be enabled or disabled.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@kleimkuhler
Copy link
Contributor Author

@adleong @hawkw Tap has now been tied to identity in the proxy config. This prevents a user from accidentally setting up a proxy environment where there is an error in expecting tap to work if identity has been explicitly disabled.

The behavior now ensures that if identity has been disabled, tap must also be explicitly disabled. If identity is enabled, then tap can either be enabled or disabled.

Once the above configuration has been verified, if tap is disabled then the tap service name is set to None. If tap is enabled, then LINKERD2_PROXY_TAP_SVC_NAME must be set.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Copy link
Member

@adleong adleong left a comment

Choose a reason for hiding this comment

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

What do you think about changing the type of Config.control_listener from Option<Listener> to Option<(Listener, identity::Name)> and getting rid of the config.tap_svc_name field? This structurally enforces that a tap server MUST have a name.

This lets us consolidate parse_control_listener and parse_tap_svc_name into one function and brings all the tap config error handling into one place.

It also simplifies serve_tap since we can be guaranteed that there will be tap_svc_name.

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@kleimkuhler
Copy link
Contributor Author

@adleong serve_tap now assumes that LINKERD2_PROXY_TAP_SVC_NAME is set in the environment if it is spawning the tap server!

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@kleimkuhler kleimkuhler requested a review from adleong August 5, 2019 21:03

admin_listener: Listen<identity::Local, ()>,
control_listener: Option<Listen<identity::Local, ()>>,
control_listener: Option<(Listen<identity::Local, ()>, identity::Name)>,
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 kept this as a tuple because we destructure it right away here. I could be convinced to add a similar TapSettings type in tap.rs, but after trying that out it seemed like a lot of boilerplate for not much of an abstraction.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kleimkuhler FWIW, it looks like we also access a field of the tuple here, which is a little unclear out of context (though not a big deal).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep I should have pointed that out too. For the clarity we gain in that access though, it still seemed a little unnecessary to add a new struct for it.

Copy link
Contributor

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

I noticed some potential test improvements + some other nits that are not really blocking.

/// Where to listen for connections initiated by the control plane.
pub control_listener: Option<Listener>,
/// Where to listen for connections initiated by the tap service.
pub control_listener: Option<TapSettings>,
Copy link
Contributor

@hawkw hawkw Aug 5, 2019

Choose a reason for hiding this comment

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

Nit/TIOLI: If this is tap-specific, and contains more than just a listener configuration, what do you think of renaming the field to tap_settings or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep sounds good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hawkw A naming change like this touches a few places in main.rs that were not before. I may default to a separate PR to keep the diff down. I feel like we usually default to this so I'm going to as well in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Especially since @adleong has already approved. I don't want to introduce additional changes that were not there before


admin_listener: Listen<identity::Local, ()>,
control_listener: Option<Listen<identity::Local, ()>>,
control_listener: Option<(Listen<identity::Local, ()>, identity::Name)>,
Copy link
Contributor

Choose a reason for hiding this comment

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

@kleimkuhler FWIW, it looks like we also access a field of the tuple here, which is a little unclear out of context (though not a big deal).

Copy link
Member

@adleong adleong left a comment

Choose a reason for hiding this comment

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

⭐ 🗜

Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@kleimkuhler
Copy link
Contributor Author

I opened linkerd/linkerd2#3197 to track renaming control_listener and possible LINKERD2_PROXY_CONTROL_LISTEN_ADDR

@kleimkuhler kleimkuhler merged commit 3acf03a into master Aug 7, 2019
@kleimkuhler kleimkuhler deleted the kleimkuhler/require-tap-svc-name branch August 7, 2019 22:18
scottcarol pushed a commit to linkerd/linkerd2 that referenced this pull request Aug 8, 2019
* update-rust-version: Check usage (linkerd/linkerd2-proxy#298)
* tap: fix tap response streams never ending (linkerd/linkerd2-proxy#299)
* Require identity on tap requests (linkerd/linkerd2-proxy#295)
* Authority label should reflect logical dst (linkerd/linkerd2-proxy#300)
* Replace futures_watch with tokio::sync::watch (linkerd/linkerd2-proxy#301)
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Aug 9, 2019
* Update h2 to v0.1.26
* Properly fall back in the dst_router (linkerd/linkerd2-proxy#291)
* Tap server authorizes clients when identity is expected (linkerd/linkerd2-proxy#290)
* update-rust-version: Check usage (linkerd/linkerd2-proxy#298)
* tap: fix tap response streams never ending (linkerd/linkerd2-proxy#299)
* Require identity on tap requests (linkerd/linkerd2-proxy#295)
* Authority label should reflect logical dst (linkerd/linkerd2-proxy#300)
* Replace futures_watch with tokio::sync::watch (linkerd/linkerd2-proxy#301)
* metrics: add `request_handle_us` histogram (linkerd/linkerd2-proxy#294)
* linkerd2-proxy: Adopt Rust 2018 (linkerd/linkerd2-proxy#302)
* Remove futures-mpsc-lossy (linkerd/linkerd2-proxy#305)
* Adopt std::convert::TryFrom (linkerd/linkerd2-proxy#304)
* lib: Rename directories to match crate names (linkerd/linkerd2-proxy#303)
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Aug 9, 2019
* update-rust-version: Check usage (linkerd/linkerd2-proxy#298)
* tap: fix tap response streams never ending (linkerd/linkerd2-proxy#299)
* Require identity on tap requests (linkerd/linkerd2-proxy#295)
* Authority label should reflect logical dst (linkerd/linkerd2-proxy#300)
* Replace futures_watch with tokio::sync::watch (linkerd/linkerd2-proxy#301)
* metrics: add `request_handle_us` histogram (linkerd/linkerd2-proxy#294)
* linkerd2-proxy: Adopt Rust 2018 (linkerd/linkerd2-proxy#302)
* Remove futures-mpsc-lossy (linkerd/linkerd2-proxy#305)
* Adopt std::convert::TryFrom (linkerd/linkerd2-proxy#304)
* lib: Rename directories to match crate names (linkerd/linkerd2-proxy#303)
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Aug 9, 2019
* update-rust-version: Check usage (linkerd/linkerd2-proxy#298)
* tap: fix tap response streams never ending (linkerd/linkerd2-proxy#299)
* Require identity on tap requests (linkerd/linkerd2-proxy#295)
* Authority label should reflect logical dst (linkerd/linkerd2-proxy#300)
* Replace futures_watch with tokio::sync::watch (linkerd/linkerd2-proxy#301)
* metrics: add `request_handle_us` histogram (linkerd/linkerd2-proxy#294)
* linkerd2-proxy: Adopt Rust 2018 (linkerd/linkerd2-proxy#302)
* Remove futures-mpsc-lossy (linkerd/linkerd2-proxy#305)
* Adopt std::convert::TryFrom (linkerd/linkerd2-proxy#304)
* lib: Rename directories to match crate names (linkerd/linkerd2-proxy#303)
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.

Tap server should be disabled when identity is disabled Tap server only accepts TLS connections

3 participants