-
Notifications
You must be signed in to change notification settings - Fork 420
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
Support OpenID Connect authentication and authorization with OpenPolicyAgent #610
Comments
The new PodTemplate field, may be a good place to add an optional sidecar, for e.g. OPA The field is added in 52a4cb6 |
Thanks for the detailed write up. The high level requirement seems to be around that Triggers has no notion of authentication/authorization for incoming requests. A lot (most?) CI/CD use cases are for triggering off of Webhook messages where the standard seems to be around using a shared secret to do some validation -- though it seems for
|
Sorry, this was a bit abstract description from my side. With GitRepoProvider I meant a provider of git repositories, e.g. GitHub, GitLab, Bitbucket Server, Bitbucket Cloud, Google Cloud Source Repositories, and similar... a provider of git repositories for customers.
The main use case for me currently is to have a BuildPipeline in cluster X that trigger a DeployPipeline in cluster Y. E.g. by sending a cloudEvent (or other http request) from the BuildPipeline to the trigger in cluster Y that then starts a run of DeployPipeline. But I am also interesting in requests from a webapp, as in the latter half of Manual approval and async PipelineRun design doc. The first case is a way to link two pipelines - with a cloudEvent sent to a trigger to start the second. From the perspective of a Trigger, this could be a single use case - supporting JWT + OPA.
Yes, that is my thoughts right know. Because the pre-shared secret and/or ssh-keypair is authorization in itself. But this can be changed/improved later if wanted.
Sounds reasonable, yes. OPA can be deployed as a DaemonSet as well. I don't know much about the interceptors, but as described here, it sounds reasonable.
Not so related to this use case. OPA is a generic policy engine, when Gabe reson about OPA it is in the role as an Admission hook. But what I want here is to use OPA for API authorization. |
OPA use rego as the language for writing the logic of authorization. There is already a proposal for a rego-interceptor: #484 In a way, using OPA as a separate service or as a rego-library is similar, but I can see a point when an organization adopt OPA sidecars to "externalize" authorization, e.g. so that you get audit-logs in a separate container. Maybe the use of rego-interceptor or OPA-interceptor should be up to the user. |
Yeah I would concur with @jlpettersson that my refs to OPA wrt access control and authorization are centered around k8s admission control, where k8s RBAC/SARs are the "baked in" k8s mechanism there. From an OPA perspective, that means https://www.openpolicyagent.org/docs/v0.12.2/kubernetes-admission-control/ Ultimately for the piece I've been advocating for in the API WG and pipelines WG, we need to allow admins to plug in either OPA or k8s RBAC/SAR based implementations as they see fit. And we need to decide if we provide anything out of the box. And we need to decide what if any doc or additional role/rolebinding defs we add to make "who can read what" more explicit. But OPA certainly overall can be used in a broader scoped than that. I haven't followed all the links @jlpettersson posted above, but in comparison to the link I just pasted above, I believe he is also minimally talking about things like OPA's "HTTP API Authorization" i.e. https://www.openpolicyagent.org/docs/v0.12.2/http-api-authorization/ OPA's "SSH and sudo Authorization" i.e. https://www.openpolicyagent.org/docs/v0.12.2/ssh-and-sudo-authorization/ as well as additional integrations. And I think even beyond what @jlpettersson has noted, I've seen OPA referenced in discussions beyond authentication/authorization into general validation, provisioning, and verdict determination. A broad foot print for sure. I'm curious how many existing contributors have dipped their toes into this pool, and have experience wiring all this into k8s based offerings. |
@jlpettersson Yeah, there is indeed an open feature request to add a built in rego interceptor like we currently have for CEL 😄 I was hoping though we could try something out even without that:
This should also accomplish the goal of keeping the audit logs in the OPA container. I can think of two possible issues here:
But aside for this, what do you think of this webhook interceptor vs the sidecar approach? |
It sounds doable, yes. An alternative is better than no alternative. |
Stale issues rot after 30d of inactivity. /lifecycle rotten Send feedback to tektoncd/plumbing. |
Rotten issues close after 30d of inactivity. /close Send feedback to tektoncd/plumbing. |
@tekton-robot: Closing this issue. In response to this:
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. |
/remove-lifecycle rotten |
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
/remove-lifecycle stale |
Hey @dibyom ... as part of iterating on my securitiy/policy/rbac etc. TEP, I'm revisiting this issue and the various discussion of options. At the moment, my opinion still is that your proposal from back in June is still the best and most "native" Tekton Triggers solution, in that it only requires OPA (vs. say Istio) and the webhook interceptor path if more of a "first class" approch from a Tekton Triggers perspective vs. the sidecar approach. With that said, why I am reaching out again here, is that it occurred to me that your pluggable interceptor TEP https://github.com/tektoncd/community/blob/master/teps/0026-interceptor-plugins.md might help make a solution more seamless. Any quick thoughts on that? And I guess if the answer is "no", thoughts on iterating on the notion of facilitating this scenario in the context of the TEP and future work for implementing it? thanks |
Yeah, one issue with the previous webhook interceptors was it was difficult to distinguish between expected and unexpected errors (i.e. #336). Pluggable interceptors should solve this . |
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
Stale issues rot after 30d of inactivity. /lifecycle rotten Send feedback to tektoncd/plumbing. |
Rotten issues close after 30d of inactivity. /close Send feedback to tektoncd/plumbing. |
@tekton-robot: Closing this issue. In response to this:
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. |
Expected Behavior
That I can use OpenID Connect authenticated request sent to the Trigger. And that I can check authorization using the OpenPolicyAgent.
Actual Behavior
Only SSH-keypair or a predefined password/credential/Secret can be used as authentication and authorization.
Additional Info
Authentication
Common types of authentication:
Examples of OpenID Connect authentication is Azure Active Directory, Sign in with Google / Google Accounts, Sign in with Apple, Keycloak, RedHat Single Sign-on. E.g. typically requests from web-apps, e.g. a dashboard.
Also Kubernetes Bounded Service Account - newer, rotated tokens is on OpenID Connect format with discovery endpoint coming in 1.18.
E.g. an upcoming, not yet existing GitRepoProvider would probably support modern OIDC serviceAccounts. E.g. It can be a provider that runs on Kubernetes (e.g. GitLab) and use the new Kubernetes ServiceAccounts for this.
Use cases
Authorization
OpenPolicyAgent is an increasingly popular tool to "externalize authorization" - e.g. for everything within an organization, e.g. Http API authZ, Kafka and other systems with a single authorization language.
This can be used for validating JWT tokens (e.g. OpenID Connect) and also do authorization e.g. if this "API-key" or JWT-token has access to this pipeline.
Final note
On a final note, I think the above can be solved by using Istio, that "inject" an opa istio sidecar. But I would like to be able to use this also without Istio, e.g. for triggering things with CloudEvents that is authenticated with a Kubernetes ServiceAccount.
Example Curl Task
and TaskRun
Example Deployment OPA sidecar
OPA can be used as a proxy in-front of a service, e.g. using Istio. Or as a sidecar that the Trigger asks (http-request) if the "event" is authorized. In a
Deployment
Also a possible solution for e.g. #572
/kind feature
The text was updated successfully, but these errors were encountered: