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

switch trigger sa based auth to impersonate; change secret ref to string and by extension same namespace as EventListener #705

Merged
merged 2 commits into from
Aug 17, 2020

Conversation

gabemontero
Copy link
Contributor

@gabemontero gabemontero commented Aug 10, 2020

Changes

As the efforts to progress support for multi-tenant event listeners has evolved, most notably around the notion of breaking out EventListenerTrigger into a Trigger CRD, or an analogous resource like a PipelineRecipe defined in the pipelines project, some evolution of the finer grained auth originally introduced in #454 seemed appropriate.

This PR currently has 2 commits with that goal in mind:

  • switch the secret reference originally introduced in introduce authentication/authorization at the EventListenerTrigger le… #454 from a ObjectReference to a LocalObjectReference, hence scoping the SA's available for use to the SA's present in the namespace of the trigger object itself; we originally scoped it as ObjectReference because the interceptors had a a multi-namespace scope for secrets per https://github.com/tektoncd/triggers/blob/master/pkg/apis/triggers/v1alpha1/event_listener_types.go#L97-L104 however as the various TEPs/proposals have evolved that no longer seems like a valid motivator for having this SA reference be multi namespace
  • as a result, the implementation for creating tekton objects under the permission of the referenced SA has been switched to use impersonation vs. construction of an actual client; this allowed for some positive changes in the roles required, but also should fit in well with how the upcoming TEPs / proposals will get implemented

And as a result this

Fixes #679

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Release Notes

  • BREAKING CHANGE: the optional EventListenerTrigger based level of authentication for creating Tekton object has had its ServiceAccount reference changed from an ObjectReference to a string ServiceAccountName, effectively enforcing that the ServiceAccount be in the same namespace as the EventListenerTrigger

@tekton-robot tekton-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Aug 10, 2020
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 10, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 36.2% -6.9
pkg/sink/sink.go 75.2% 76.3% 1.0

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 36.2% -6.9
pkg/sink/sink.go 75.2% 76.3% 1.0

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 38.2% -4.9
pkg/sink/sink.go 75.2% 76.3% 1.0

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 10, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 38.2% -4.9
pkg/sink/sink.go 75.2% 76.3% 1.0

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 38.2% -4.9
pkg/sink/sink.go 75.2% 76.3% 1.0

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 38.2% -4.9
pkg/sink/sink.go 75.2% 76.3% 1.0

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 38.2% -4.9
pkg/sink/sink.go 75.2% 76.3% 1.0

@gabemontero gabemontero changed the title WIP: switch trigger sa based auth to impersonate switch trigger sa based auth to impersonate; change secret ref to LocalObjectReference Aug 11, 2020
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 11, 2020
@gabemontero
Copy link
Contributor Author

gabemontero commented Aug 11, 2020

/assign @dibyom
/assign @khrm

details in the description gentlemen

similar in spirit to #704 but a more comprehensive change as it evolves the support I added back in Feb / Mar of this year.

@dibyom
Copy link
Member

dibyom commented Aug 11, 2020

Thanks @gabemontero I think this should address #679 too?

@gabemontero
Copy link
Contributor Author

Thanks @gabemontero I think this should address #679 too?

yes it does @dibyom

@gabemontero
Copy link
Contributor Author

forgot to

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 11, 2020
Copy link
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

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

/lgtm

I think we should move to ServiceAccountName string instead of taking it as ServiceAccount LocalObjectReference. Maybe a pr later on which deprecate ServiceAccount in favour of ServiceAccountName.

Then, this will have the same format as we do in other Tekton resources which requires ServiceAccount.

@gabemontero
Copy link
Contributor Author

/lgtm

I think we should move to ServiceAccountName string instead of taking it as ServiceAccount LocalObjectReference. Maybe a pr later on which deprecate ServiceAccount in favour of ServiceAccountName.

Then, this will have the same format as we do in other Tekton resources which requires ServiceAccount.

I'm fine with switching to ServiceAccountName with this PR. I'll do that momentarily, and then between the two of you @khrm @dibyom unless anything else comes to mind, feel free to both approve and lgtm. Of course if @dibyom has issue with the move off of LocalObjectReference we can discuss further.

thanks

@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 13, 2020
@gabemontero gabemontero changed the title switch trigger sa based auth to impersonate; change secret ref to LocalObjectReference switch trigger sa based auth to impersonate; change secret ref to string and by extension same namespace as EventListener Aug 13, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 0.0% -43.1
pkg/sink/sink.go 75.2% 76.3% 1.0

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 0.0% -43.1
pkg/sink/sink.go 75.2% 76.3% 1.0

@gabemontero
Copy link
Contributor Author

switch from LocalObjectReference to string pushed

adjusted PR title

Also added Fixes #679 note in description

@dibyom @khrm PTAL

@gabemontero
Copy link
Contributor Author

gabemontero commented Aug 13, 2020

oh and I removed more unneeded code from auth_override.go, hence the delta change

we are now down to one method which we have to use the "fake" version of in the unit tests to bypass actual client access to a cluster

the function is covered by the e2e that validates trigger level SA

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 0.0% -43.1
pkg/sink/sink.go 75.2% 76.3% 1.0

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 0.0% -43.1
pkg/sink/sink.go 75.2% 76.3% 1.0

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 0.0% -43.1
pkg/sink/sink.go 75.2% 76.3% 1.0

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/auth_override.go 43.1% 0.0% -43.1
pkg/sink/sink.go 75.2% 76.3% 1.0

@gabemontero
Copy link
Contributor Author

tests back to green after the switch to serviceAccountName string

PTAL @khrm @dibyom

@dibyom
Copy link
Member

dibyom commented Aug 13, 2020

/approve

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 13, 2020
@dibyom
Copy link
Member

dibyom commented Aug 13, 2020

oh and I removed more unneeded code from auth_override.go, hence the delta change

we are now down to one method which we have to use the "fake" version of in the unit tests to bypass actual client access to a cluster

the function is covered by the e2e that validates trigger level SA

Thanks for the clarification!

Copy link
Contributor

@khrm khrm left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 17, 2020
@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom, khrm

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

@tekton-robot tekton-robot merged commit 79884ef into tektoncd:master Aug 17, 2020
@gabemontero gabemontero deleted the trigger-sa-impersonate branch August 17, 2020 12:49
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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config to turn-off Trigger's namespaced SA impersonation
4 participants