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

Service identity injection to request payload #1256

Closed
rucciva opened this issue Dec 2, 2020 · 22 comments · Fixed by #1941
Closed

Service identity injection to request payload #1256

rucciva opened this issue Dec 2, 2020 · 22 comments · Fixed by #1941
Labels
area/envoy area/kuma-cp kind/feature New feature triage/accepted The issue was reviewed and is complete enough to start working on it triage/stale Inactive for some time. It will be triaged again

Comments

@rucciva
Copy link

rucciva commented Dec 2, 2020

Summary

A service might implement a custom Accounting logic. Meanwhile in service mesh scenario, it is preferred to delegate Authentication and Authorization to the data plane, making the receiving service unaware of the caller identity. Thus it would be preferable if the caller identity can be made available to the receiving service, .e.g through HTTP header injection.

Steps To Reproduce

Additional Details & Logs

  • Version: 1.0.1
  • Error logs: -
  • Configuration: -
  • Platform and Operating System: -
@subnetmarco
Copy link
Contributor

subnetmarco commented Dec 3, 2020

This would be quite simple to implement, I would assume (at least for HTTP requests). We could be returning two headers:

  • X-Kuma-Forwarded-Client-Cert, with the full Spiffe entry.
  • X-Kuma-Forwarded-Client-Service, with the service name only.

And perhaps:

  • X-Kuma-Forwarded-Client-Zone, with the service zone name only.

@slonka
Copy link
Contributor

slonka commented Dec 6, 2020

Just a couple of things to keep in mind when implementing this:

If you want the full spiffie entry you can use https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#extensions-filters-network-http-connection-manager-v3-httpconnectionmanager-setcurrentclientcertdetails and set the type to URI (side note: from my experience developers do not want the full spiffie entry, and making everyone parse that themselves is pointless).

For the service name you have to manually extract it. The SAN URI part is available via Lua scripts, an example usage is here: https://github.com/allegro/envoy-control/blob/master/envoy-control-core/src/main/resources/lua/ingress_client_name_header.lua#L12 , but make sure you use Envoy version higher than 59e29685d33bd730c76ccb3b8383b666c0942523 (a couple of commits after 1.16.0 edit: 1.16.1) otherwise you’ll encounter Envoy SEGFAULT after a couple of requests pass through that script (details here: envoyproxy/envoy#14092).

Kuma identifies services by SAN URI: spiffe://{mesh}/{service} so additional question to @subnetmarco - by “service zone” name only you mean the first part of the URI “{mesh}“ right?

@nickolaev
Copy link
Contributor

Thanks for the pointers @slonka. We have already adopted envoy 1.16.1, so that should not be a problem.
About your last question, I guess @subnetmarco referees to the kuma multi-zone deployments, where we have distributed/hybrid deployments. So a zone would be something like dc-us-east or dc-eu-north.

@slonka
Copy link
Contributor

slonka commented Dec 7, 2020

@nickolaev I'm sorry I was mistaken v1.16.1 was released 2020-11-20 18:43:35 -0800 and that fix was merged 2020-11-23 09:54:37 +0100 so you still need to upgrade if you want to use that feature.

@jewertow
Copy link
Contributor

I will work on this issue.

@jewertow
Copy link
Contributor

jewertow commented May 17, 2021

@rucciva you can get service identity from the header x-forwarded-client-cert. This header has the following content:

X-Forwarded-Client-Cert By=spiffe://{mesh}/{service};Hash={hash};URI=spiffe://{mesh}/{service}

So you can parse this header, get URI and retrieve name of the service.

I will come back to this feature the next week and I will implement headers proposed by @subnetmarco.

@slonka thank you very much for your hints. They were very helpful.

@lahabana lahabana reopened this Nov 30, 2021
@lahabana lahabana changed the title Feature Request: Service identity injection to request payload Service identity injection to request payload Nov 30, 2021
@github-actions github-actions bot added the triage/pending This issue will be looked at on the next triage meeting label Nov 30, 2021
@lahabana lahabana added triage/accepted The issue was reviewed and is complete enough to start working on it and removed triage/pending This issue will be looked at on the next triage meeting labels Dec 9, 2021
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jan 14, 2022
@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Jan 14, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Feb 14, 2022
@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Apr 26, 2022
@rohank2002
Copy link

I see that that the pull request was merged, is this issue resolved? I was testing internal mtls using Kuma. I used a podinfo deployment for getting the headers from the request. I couldn't see the XFCC header.

@lahabana
Copy link
Contributor

I think the issue is still open because the implementation was never completed. @jakubdyszkiewicz do you have more ctx?

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jun 24, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@lahabana lahabana added triage/pending This issue will be looked at on the next triage meeting and removed triage/accepted The issue was reviewed and is complete enough to start working on it triage/stale Inactive for some time. It will be triaged again labels Jun 27, 2022
@slonka
Copy link
Contributor

slonka commented Jun 28, 2022

The issue is still open because this was not merged: #2158 (comment) right?

@scottslowe
Copy link

+1 for finishing up the implementation of this functionality

@slonka
Copy link
Contributor

slonka commented Jul 29, 2022

For these headers to be injected appProtocol needs to be set to http or grpc https://kuma.io/docs/1.7.x/policies/protocol-support-in-kuma/#protocol-support-in-kuma

(edited)

@jakubdyszkiewicz jakubdyszkiewicz added triage/accepted The issue was reviewed and is complete enough to start working on it and removed triage/pending This issue will be looked at on the next triage meeting labels Sep 7, 2022
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Dec 7, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2022

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Dec 7, 2022
@whiskeysierra
Copy link

For these headers to be injected appProtocol needs to be set to http https://kuma.io/docs/1.7.x/policies/protocol-support-in-kuma/#protocol-support-in-kuma

Shouldn't grpc work as well?

@slonka
Copy link
Contributor

slonka commented Jan 26, 2023

Shouldn't grpc work as well?

you're right, it just needs to be different than tcp

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Apr 27, 2023
@github-actions
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Apr 27, 2023
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jul 27, 2023
@github-actions
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Jul 27, 2023
@github-actions
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Oct 26, 2023
@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Nov 2, 2023
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Feb 1, 2024
Copy link
Contributor

github-actions bot commented Feb 1, 2024

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@slonka
Copy link
Contributor

slonka commented Feb 7, 2024

AFAIK this is solved (with the full entry, clients have to extract name manually), you just need to make sure you mark the app with protocol http/grpc. Closing, if something does not work please reopen.

@slonka slonka closed this as completed Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/envoy area/kuma-cp kind/feature New feature triage/accepted The issue was reviewed and is complete enough to start working on it triage/stale Inactive for some time. It will be triaged again
Projects
None yet
10 participants