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

[OCPNODE-1671] Add ClusterImagePolicy and ImagePolicy #1457

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

QiWang19
Copy link
Member

@QiWang19 QiWang19 commented May 10, 2023

Add ImagePolicy struct of ImagePolicy CRD for image sigstore signature verification.
enhancement: openshift/enhancements#1402
Epic: https://issues.redhat.com/browse/OCPNODE-1628

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 10, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 10, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 10, 2023

Hello @QiWang19! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

@openshift-ci openshift-ci bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 10, 2023
@QiWang19 QiWang19 changed the title [WIP] Add ClusterImageSigPolicy Add ClusterImageSigPolicy May 23, 2023
@QiWang19 QiWang19 marked this pull request as ready for review May 23, 2023 04:30
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 23, 2023
@openshift-ci openshift-ci bot requested review from adambkaplan and mfojtik May 23, 2023 04:30
@QiWang19
Copy link
Member Author

@saschagrunert could you review the api?

config/v1alpha1/types_image_policy.go Outdated Show resolved Hide resolved
config/v1alpha1/types_image_policy.go Outdated Show resolved Hide resolved
@QiWang19 QiWang19 changed the title Add ClusterImageSigPolicy Add ImageSigPolicy May 26, 2023
@QiWang19 QiWang19 changed the title Add ImageSigPolicy Add ImagePolicy May 26, 2023
@QiWang19 QiWang19 force-pushed the draft-sigstore branch 4 times, most recently from 484198d to eb77406 Compare June 2, 2023 11:09
@openshift-ci openshift-ci bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 2, 2023
@QiWang19 QiWang19 force-pushed the draft-sigstore branch 6 times, most recently from 2f22c0b to 0d6b7b0 Compare July 1, 2023 01:24
@QiWang19 QiWang19 changed the title Add ImagePolicy [OCPNODE-1671] Add ImagePolicy Jul 3, 2023

// PublicKey defines the root of trust based on a sigstore public key.
type PublicKey struct {
// keyData contains inline base64 encoded data of the public key.
Copy link
Contributor

Choose a reason for hiding this comment

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

This one didn't get PEM encoding change

// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=8192
KeyData string `json:"keyData"`
// rekorKeyData contains inline base64 data of the Rekor public key.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should mention pem format

Comment on lines 126 to 127
// oidcIssuer contains the expected OIDC issuer.
// Example: "https://expected.OIDC.issuer/"
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we expecting the OIDC issuer to expose the well known endpoint under this path?

@JoelSpeed
Copy link
Contributor

I think the OIDC issuer field needs a little more depth to the godoc there. I assume, since I'm semi familiar with OIDC, that the expectation is that the URL will be prepended to /.well-known/openid-configuration before making a request to discover the endpoints, right?

In that case I'd want to mention that the issue URL should be the full URL including any subpath that the issuer is hosted on and that the issuer URL will be used to discover jwt keys or whatever it's being used for

@QiWang19
Copy link
Member Author

Please remove the second commit, we should not be merging the types without the CRD and tests. What is the motivation for the second commit? Is this feature going to land in 4.15?

I am not sure the implementation for these CRDs can be finished before the feature freeze. The second commit can have the API built and we can develop and test the CRD functions on the cluster.
we can get the second commit back, is it ok to have the CRD registered as techpreview in 4.15, and not have underlying support for it?

@QiWang19
Copy link
Member Author

QiWang19 commented Nov 27, 2023

we have merged the feature gate #1470 for this API.

@QiWang19
Copy link
Member Author

I think the OIDC issuer field needs a little more depth to the godoc there. I assume, since I'm semi familiar with OIDC, that the expectation is that the URL will be prepended to /.well-known/openid-configuration before making a request to discover the endpoints, right?

In that case I'd want to mention that the issue URL should be the full URL including any subpath that the issuer is hosted on and that the issuer URL will be used to discover jwt keys or whatever it's being used for

@mtrmac Could you take a look? We added the check for oidcIssuer to just validate it is a valid URL. I am not sure if we can add other specific validation for it. I don't see explicit restrictions from the doc https://docs.sigstore.dev/certificate_authority/oidc-in-fulcio/#uri

@mtrmac
Copy link
Contributor

mtrmac commented Nov 27, 2023

I think the OIDC issuer field needs a little more depth to the godoc there. I assume, since I'm semi familiar with OIDC, that the expectation is that the URL will be prepended to /.well-known/openid-configuration before making a request to discover the endpoints, right?

… and that the issuer URL will be used to discover jwt keys or whatever it's being used for

It’s that kind of value, yes, but not necessarily precisely that one, and nothing is going to reach out to the URL. Verification happens off-line.

What is actually verified is that the Fulcio-issued certificate contains a (Fulcio-defined) certificate extension pointing at the user-specified URL. And when Fulcio issues certificates, it includes a value based on an URL inside the client-provided ID token. It is usually the "iss" field from the ID token, but there is a mapping mechanism, activated in the default configuration https://github.com/sigstore/fulcio/blob/4230267565c9c3082302cdca62b6bf612db11bd4/pkg/config/config.go#L397 .

So the closest direct spec is the iss field in https://openid.net/specs/openid-connect-core-1_0.html#IDToken ; but note https://openid.net/specs/openid-connect-core-1_0.html#GoogleIss .

c/image does not do any validation of the string, and requires a (byte-for-byte) exact match between the configuration and the certificate extension field. So I would caution against any effort to normalize the users’ input.

(I’m afraid I haven’t been paying close attention to this PR.)

@openshift-ci openshift-ci bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 27, 2023
@QiWang19
Copy link
Member Author

/test e2e-azure

@QiWang19
Copy link
Member Author

@JoelSpeed PTAL

@JoelSpeed
Copy link
Contributor

@mtrmac Would it be fair then to add to the oidcIssuer field an expanded comment that explains what you've just said? That this should typically match the issuer field in the ...

That way users might have an idea of where they may be able to find this value or verify the value matches some other source at the least

@mtrmac
Copy link
Contributor

mtrmac commented Nov 28, 2023

The c/image documentation just says

Both oidcIssuer and subjectEmail are mandatory,
exactly specifying the expected identity provider, and the identity of the user obtaining the Fulcio certificate.

I don’t have a strong opinion on whether the details of the field mapping are worth emphasizing.

In the worst case, the signature enforcement currently fails with "Unexpected Fulcio OIDC issuer %q" on this code path, so users learn what value to use that way.

Add API for ClusterImagePolicy, ImagePolicy CRD

Signed-off-by: Qi Wang <[email protected]>
@QiWang19
Copy link
Member Author

@JoelSpeed I updated the comment for oidcIssuer, PTAL

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 12, 2023
Copy link
Contributor

openshift-ci bot commented Dec 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JoelSpeed, QiWang19, saschagrunert

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 12, 2023
Copy link
Contributor

openshift-ci bot commented Dec 12, 2023

@QiWang19: all tests passed!

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@openshift-bot
Copy link

[ART PR BUILD NOTIFIER]

This PR has been included in build ose-cluster-config-api-container-v4.16.0-202312130634.p0.gef62af0.assembly.stream for distgit ose-cluster-config-api.
All builds following this will include this PR.

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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants