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

OIDC auth extension header handling should be case-insensitive #18405

Closed
alexvanboxel opened this issue Feb 7, 2023 · 6 comments
Closed

OIDC auth extension header handling should be case-insensitive #18405

alexvanboxel opened this issue Feb 7, 2023 · 6 comments
Labels
bug Something isn't working extension/oidcauth

Comments

@alexvanboxel
Copy link
Contributor

Component(s)

extension/oidcauth

What happened?

Description

The OIDC auth extension header handling should be case-insensitive; also the default header key is declared as authorization, while most systems provide the Authorization header capitalized. The HTTP spec also specifies that HTTP headers are case-insensitive.

Steps to Reproduce

Use the OIDC extension, without specifying the attribute key (so default is used), do a call with a JWT bearer token, with as key the capitalized Authorization.

Expected Result

200 OK

Actual Result

401 Unauthorized

Collector version

0.77

Environment information

Environment

OS: MacOS

OpenTelemetry Collector configuration

receivers:
  googlecloudpubsub:
    mode: "push"
    project: collibra-telemetry
    subscription: projects/acme/subscriptions/test
    push:
      path: "/"
      endpoint: "0.0.0.0:${PORT}"
      auth:
        authenticator: oidc

extensions:
  oidc:
    issuer_url: https://accounts.google.com
    audience: otel
    username_claim: email
    attribute: Authorization

processors:
  batch:

exporters:
  logging:
    logLevel: info

service:
  extensions: [oidc]
  pipelines:
    traces:
      receivers: [googlecloudpubsub]
      exporters: [logging]
    metrics:
      receivers: [googlecloudpubsub]
      exporters: [logging]
    logs:
      receivers: [googlecloudpubsub]
      exporters: [logging]

  telemetry:
    logs:
      level: INFO

Log output

No response

Additional context

Workaround for now, declare the attribute explicitly:

  oidc:
    # https://accounts.google.com/.well-known/openid-configuration
    issuer_url: https://accounts.google.com
    audience: otel
    username_claim: email
    attribute: Authorization```
@alexvanboxel alexvanboxel added bug Something isn't working needs triage New item requiring triage labels Feb 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@jpkrohling
Copy link
Member

Interesting, this should have been fixed by this: open-telemetry/opentelemetry-collector#5646

Would you be interested in looking at the source code and figuring out why this isn't happening?

@jpkrohling jpkrohling removed the needs triage New item requiring triage label Feb 7, 2023
@jpkrohling
Copy link
Member

Here's the problematic code:

authHeaders := headers[e.cfg.Attribute]
if len(authHeaders) == 0 {
return ctx, errNotAuthenticated
}

Perhaps a similar solution to the PR I linked earlier would apply here:
https://github.com/open-telemetry/opentelemetry-collector/blob/1ca481b86e1856ad25dbe2598340cc9066d7f950/client/client.go#L161-L183

@alexvanboxel
Copy link
Contributor Author

Yes, a similar solution will work. First, I need to finish my upcoming revision for the googlepubsubreceiver (that will use this extension in push mode).

@alexvanboxel
Copy link
Contributor Author

@jpkrohling the PR is green, and waiting for review: #18607

@andrzej-stencel
Copy link
Member

You specified "Collector version 0.77", but this version didn't exist at the time of filing this issue 🙃
I think you meant v0.70.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working extension/oidcauth
Projects
None yet
Development

No branches or pull requests

3 participants