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

mt-broker-filter: reject request for wrong audience #7427

Merged
merged 8 commits into from
Dec 4, 2023

Conversation

xiangpingjiang
Copy link
Contributor

Fixes #7291

Proposed Changes

  • 🎁 If OIDC authentication is enabled, mt-broker-filter will check if the audience of the received token matches the audience of the Triggers Subscription. If not it will respond with a 401

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Release Note


Docs

@xiangpingjiang xiangpingjiang marked this pull request as draft November 5, 2023 15:52
@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 5, 2023
Copy link

knative-prow bot commented Nov 5, 2023

Hi @xiangpingjiang. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow knative-prow bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 5, 2023
@knative-prow knative-prow bot requested review from aliok and lionelvillard November 5, 2023 15:52
Copy link

codecov bot commented Nov 5, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (3fcc78a) 76.70% compared to head (7ec92be) 76.63%.

Files Patch % Lines
pkg/broker/filter/filter_handler.go 17.64% 13 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7427      +/-   ##
==========================================
- Coverage   76.70%   76.63%   -0.08%     
==========================================
  Files         259      259              
  Lines       14254    14270      +16     
==========================================
+ Hits        10934    10936       +2     
- Misses       2765     2778      +13     
- Partials      555      556       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: pingjiang <[email protected]>
@creydr
Copy link
Member

creydr commented Nov 10, 2023

Hello @xiangpingjiang,
thanks for working on this. Do you have an ETA, when this PR is ready for review?

@xiangpingjiang
Copy link
Contributor Author

Hello @xiangpingjiang, thanks for working on this. Do you have an ETA, when this PR is ready for review?

hello, @creydr
I will try to finish it in the next two weeks.

@creydr
Copy link
Member

creydr commented Nov 24, 2023

Hello @xiangpingjiang,
thanks for your work on this PR so far. Is there anything we can help you to finish this?

@creydr creydr self-assigned this Nov 24, 2023
@xiangpingjiang
Copy link
Contributor Author

Hello @xiangpingjiang, thanks for your work on this PR so far. Is there anything we can help you to finish this?

hello, @creydr
I saw there was a auth e2e test failed. I tried to run it locally to find the reason. But blocked by ko and Local Registry in kind or minikube.

Is there a way to build the image by docker not by ko ?

@creydr
Copy link
Member

creydr commented Nov 27, 2023

hello, @creydr I saw there was a auth e2e test failed. I tried to run it locally to find the reason. But blocked by ko and Local Registry in kind or minikube.

Is there a way to build the image by docker not by ko ?

Hello @xiangpingjiang,
AFAIK there is no direct way without ko (you would need to create a Dockerfile, ...). What are the issues you face? For another repo, we have a kind setup script, which adds a local registry (then available at localhost:5001): https://github.com/knative-extensions/eventing-kafka-broker/blob/main/hack/create-kind-cluster.sh

then you could apply via KO_DOCKER_REPO=localhost:5001 ko apply ...

Edit: you need to update line 51 to:

        "service-account-issuer": "https://kubernetes.default.svc"

@xiangpingjiang
Copy link
Contributor Author

hello, @creydr I saw there was a auth e2e test failed. I tried to run it locally to find the reason. But blocked by ko and Local Registry in kind or minikube.
Is there a way to build the image by docker not by ko ?

Hello @xiangpingjiang, AFAIK there is no direct way without ko (you would need to create a Dockerfile, ...). What are the issues you face? For another repo, we have a kind setup script, which adds a local registry (then available at localhost:5001): https://github.com/knative-extensions/eventing-kafka-broker/blob/main/hack/create-kind-cluster.sh

then you could apply via KO_DOCKER_REPO=localhost:5001 ko apply ...

Edit: you need to update line 51 to:

        "service-account-issuer": "https://kubernetes.default.svc"

Thanks, I will try that

Copy link
Member

@creydr creydr left a comment

Choose a reason for hiding this comment

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

Hey @xiangpingjiang,
I just went over your PR and saw something, what probably makes the implementation easier.

pkg/broker/filter/filter_handler.go Outdated Show resolved Hide resolved
pkg/broker/filter/filter_handler.go Outdated Show resolved Hide resolved
Signed-off-by: pingjiang <[email protected]>
@creydr
Copy link
Member

creydr commented Dec 2, 2023

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 2, 2023
Copy link
Member

@creydr creydr left a comment

Choose a reason for hiding this comment

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

It seems your PR could need a rebase to get the latest changes & fixes from main to have some e2e tests passing here too.

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 4, 2023
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 4, 2023
@creydr
Copy link
Member

creydr commented Dec 4, 2023

@xiangpingjiang thanks for the update. Can you mark the PR "ready for review", when it's done from your side?

@xiangpingjiang xiangpingjiang marked this pull request as ready for review December 4, 2023 11:17
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 4, 2023
@knative-prow knative-prow bot requested review from creydr and pierDipi December 4, 2023 11:17
@creydr
Copy link
Member

creydr commented Dec 4, 2023

/retest

Copy link
Member

@creydr creydr left a comment

Choose a reason for hiding this comment

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

Thanks a lot @xiangpingjiang for your contribution on this and solving this issue!
👍

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Dec 4, 2023
Copy link

knative-prow bot commented Dec 4, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: creydr, xiangpingjiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 4, 2023
@knative-prow knative-prow bot merged commit 79bb385 into knative:main Dec 4, 2023
33 of 34 checks passed
@xiangpingjiang xiangpingjiang deleted the mt-broker-filter branch February 3, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mt-broker-filter: reject request for wrong audience
3 participants