-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add auth support for collector #2570
Add auth support for collector #2570
Conversation
@yurishkuro are the lint problems known? I don't think they are related to this PR. |
you're upgrading grpc dependencies (not recommended as part of functional PRs), so the lint errors are related to this PR. |
I changed the code to not require adding the OpenTelemetry Collector as a dependency to the main module. |
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
Codecov Report
@@ Coverage Diff @@
## master #2570 +/- ##
==========================================
+ Coverage 95.31% 95.33% +0.01%
==========================================
Files 208 208
Lines 9281 9294 +13
==========================================
+ Hits 8846 8860 +14
+ Misses 356 355 -1
Partials 79 79
Continue to review full report at Codecov.
|
cmd/collector/app/builder_flags.go
Outdated
flags.String(authOIDCIssuerURL, "", "the OpenID Connect server to validate the incoming auth tokens") | ||
flags.String(authOIDCIssuerCAPath, "", "the path to the issuer's CA") | ||
flags.String(authOIDCClientID, "", "this Jaeger's client ID") | ||
flags.String(authOIDCUsernameClaim, "", "the username claim in the token, in case the 'sub' field shouldn't be used") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/shouldn't be/isn't being/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure -- the sub
field is always used, unless this flag is set. What's the right way to convey that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see -- maybe something like "The username claim in the token which, if set, overrides the 'sub' field"? (although, I'm not sure what the 'sub' field refers to :P)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sub
is a standard field in JWT (JSON Web Tokens), indicating the "subject" (username).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?
the claim in the token that should be used for the username instead of the default 'sub' field.
cmd/opentelemetry/app/receiver/jaegerreceiver/jaeger_receiver.go
Outdated
Show resolved
Hide resolved
LGTM, just had a few nit comments. I'll defer approval to maintainers. Thanks for the nice testing instructions! I tried "Testing the Agent part from this PR" and got this error in Jaeger agent:
The "Testing the Collector part of this PR" instructions seemed to work though, saw this in OTEL agent (with logging exporter added):
It's quite likely I stuffed something up in the first test, just thought to inform you anyway. |
Did you use the token from the instructions, or did you setup your own Auth0 application? If you are using the token from the example, it's likely expired by now. |
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
if cfg.GRPC != nil && len(cOpts.AuthOIDCIssuerURL) > 0 { | ||
// TODO: how can we log a warning if the user fails to specify a conditionally required flag? | ||
// if authOIDCIssuerURL is set, authOIDCClientID has to be set as well (and vice-versa). | ||
cfg.GRPC.Auth = &configauth.Authentication{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if it's possible atm, but I feel like an unsigned token mode would be valuable. If you didn't want to muck with oidc but just wanted to generate some simple tokens for multitenancy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's record this as an issue. I don't think people would actually do that in production environments, but I could be wrong.
@@ -96,6 +110,14 @@ func AddFlags(flags *flag.FlagSet) { | |||
func AddOTELJaegerFlags(flags *flag.FlagSet) { | |||
flags.String(CollectorHTTPHostPort, ports.PortToHostPort(ports.CollectorHTTP), "The host:port (e.g. 127.0.0.1:14268 or :14268) of the collector's HTTP server") | |||
flags.String(CollectorGRPCHostPort, ports.PortToHostPort(ports.CollectorGRPC), "The host:port (e.g. 127.0.0.1:14250 or :14250) of the collector's GRPC server") | |||
|
|||
// auth-related flags | |||
flags.String(authOIDCIssuerURL, "", "the OpenID Connect server to validate the incoming auth tokens") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't these flags start showing up on the Jaeger collector but be unsupported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They shouldn't, as they are part of AddOTELJaegerFlags
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AddOtelJaegerFlags
is called from the normal AddFlags
here:
https://github.com/jaegertracing/jaeger/blob/master/cmd/collector/app/builder_flags.go#L91
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely right:
$ go run ./cmd/collector/ --help | grep oidc
2020/10/23 22:13:16 maxprocs: Leaving GOMAXPROCS=12: CPU quota undefined
--collector.auth.oidc.client-id string this Jaeger's client ID
--collector.auth.oidc.groups-claim string the claim containing the group membership, where each group is considered a tenant. When absent, multi-tenancy is disabled.
--collector.auth.oidc.issuer-ca-path string the path to the issuer's CA
--collector.auth.oidc.issuer-url string the OpenID Connect server to validate the incoming auth tokens
--collector.auth.oidc.username-claim string the claim in the token that should be used for the username instead of the default 'sub' field
I should probably suppress the flags from the current collector.
Yup, I was using the token from the instructions, and probably the cause of the error. |
I'm changing this to a draft PR, as we probably want to figure out our OpenTelemetry strategy before merging this here. |
I'm closing this, as we'll likely not need this if we move the direction we agreed. |
Which problem is this PR solving?
Short description of the changes
Testing the Agent part from this PR
Start the OpenTelemetry Collector with this configuration:
And the agent from this PR with the following flags:
"--auth.bearer.token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImxiWmJrd2JHUXlrWGdub09mRXNRNCJ9.eyJpc3MiOiJodHRwczovL2Rldi16a2toZjg3NC5ldS5hdXRoMC5jb20vIiwic3ViIjoiMUpEUmZJMm43c0JhNnhvMkQ2VEJSVnpjbGs5M25uVUZAY2xpZW50cyIsImF1ZCI6Imh0dHA6Ly9hdXRoLmV4YW1wbGUuY29tIiwiaWF0IjoxNjAyNzU0NDU0LCJleHAiOjE2MDI4NDA4NTQsImF6cCI6IjFKRFJmSTJuN3NCYTZ4bzJENlRCUlZ6Y2xrOTNublVGIiwiZ3R5IjoiY2xpZW50LWNyZWRlbnRpYWxzIn0.R128iWgn68uW_dPOifsYSRI2Yon4_CU-8E8gJeAvoIVQCka3u0S5RZ8C_I8zvLjdcuKePO9PjOp2vh9VcntXAZtc0II3D_K-fAXEsYE6aVM5taJFXnNwb7UAje0yfvMChXTVHfjcJkW8c-i3OrilJ9Ab-8ZSLDaR_a6cuT2c8BGj57tmDV2sWVJwe-dUCOzIPdwocQNK-pC9RsDTyq2uUMpqTRulyKlp51u2PtLd7tBjW1yZokoZcAlsVb4dJm4ZCutYZ4_tkeYSojZKw6JhhSDxcKvTAY4Y7nrMh2pGgjZbll1yzlsL1TyvD0PUWwM24wlDln5O0l4nU1Dzw6F8Wg",
"--reporter.grpc.host-port=localhost:14250",
"--reporter.grpc.tls.enabled=true",
"--reporter.grpc.tls.ca=/home/jpkroehling/Projects/src/github.com/open-telemetry/opentelemetry-collector/local/ca.pem",
Finally, send a trace with, for instance, Jaeger's tracegen:
$ go run ./cmd/tracegen/ -traces 1
Testing the Collector part of this PR
Start the Jaeger Collector with the following flags:
"--collector.auth.oidc.client-id=http://auth.example.com",
"--collector.auth.oidc.issuer-url=https://dev-zkkhf874.eu.auth0.com/",
"--collector.grpc.tls.cert=/home/jpkroehling/Projects/src/github.com/open-telemetry/opentelemetry-collector/local/self-signed.pem",
"--collector.grpc.tls.key=/home/jpkroehling/Projects/src/github.com/open-telemetry/opentelemetry-collector/local/self-signed-key.pem",
"--collector.grpc.tls.enabled=true",
And an OpenTelemetry Collector with this config:
And finally, send a trace with, for instance, OpenTelemetry's tracegen:
$ go run . -otlp-endpoint localhost:56680 -otlp-insecure -traces 1
Negative tests
Just change the bearer token to something else in either of the cases.
Signed-off-by: Juraci Paixão Kröhling juraci@kroehling.de