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

HOSTEDCP-1257: control-plane-pki-operator: add a CSR flow for break-glass creds #3267

Merged
merged 7 commits into from Dec 12, 2023

Conversation

stevekuznetsov
Copy link
Contributor

In order to acquire break-glass credentials, end users will not have access to the management plane from which they can read certificates. Instead, we expect them to create (by proxy) a CertificateSigningRequest that we will sign, if it is approved.

/cc @sjenning @csrwng @enxebre

@openshift-ci-robot
Copy link

openshift-ci-robot commented Dec 1, 2023

@stevekuznetsov: This pull request references HOSTEDCP-1256 which is a valid jira issue.

In response to this:

In order to acquire break-glass credentials, end users will not have access to the management plane from which they can read certificates. Instead, we expect them to create (by proxy) a CertificateSigningRequest that we will sign, if it is approved.

/cc @sjenning @csrwng @enxebre

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.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Dec 1, 2023
@openshift-ci openshift-ci bot added do-not-merge/needs-area area/ci-tooling Indicates the PR includes changes for CI or tooling area/cli Indicates the PR includes changes for CLI area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/testing Indicates the PR includes changes for e2e testing and removed do-not-merge/needs-area labels Dec 1, 2023
Copy link

netlify bot commented Dec 1, 2023

Deploy Preview for hypershift-docs ready!

Name Link
🔨 Latest commit e104187
🔍 Latest deploy log https://app.netlify.com/sites/hypershift-docs/deploys/656e3d7589347b000870bedd
😎 Deploy Preview https://deploy-preview-3267--hypershift-docs.netlify.app/reference/api
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
@stevekuznetsov stevekuznetsov force-pushed the skuznets/pki-csr branch 2 times, most recently from 3be2099 to 22eb99a Compare December 1, 2023 02:01
@@ -0,0 +1,185 @@
/*
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have a policy for wholesale copy-paste of modules? Upstream made it clear they would not be OK with exporting this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would at least add a comment saying where this came from

type ValidatorFunc func(csr *certificatesv1.CertificateSigningRequest, x509cr *x509.CertificateRequest) error

// Validator returns a function that validates CertificateSigningRequests
func Validator(hcp *hypershiftv1beta1.HostedControlPlane, signer SignerClass) ValidatorFunc {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please review this - we're declaring what kinds of CSRs we accept here.

der, err := ca.Sign(x509cr.Raw, authority.PermissiveSigningPolicy{
TTL: duration(certTTL, expirationSeconds),
Usages: usages,
Backdate: backdate, // this must always be less than the minimum TTL requested by a user (see sanity check requestedDuration below)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please review backdating & validity - as written, it's the same as upstream k8s signers.

return pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: der}), nil
}

func duration(certTTL time.Duration, expirationSeconds *int32) time.Duration {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please review duration policy - as written, it's the same as upstream k8s signers.

kubeInformersForNamespaces,
kubeClient,
controllerContext.EventRecorder,
36*certRotationScale/24,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please review TTL.

@@ -0,0 +1,80 @@
package controlplanepkioperator
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file (and the test) don't follow the convention in this controller, but the convention is to put everything in disjoint places and many thousand-line-files so I hope that's ok


// signing the certificate necessarily uses cryptographic randomness, so we can't know
// what the output will be a priori
if testCase.expectedCfg != nil && testCase.expectedCfg.Status != nil && testCase.expectedCfg.Status.Certificate != nil &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unfortunate but I don't know of any way for us to avoid it. Essentially we end up asserting that if the test case expected something in the signed certificate field, there is some value - any value - there.

@stevekuznetsov stevekuznetsov force-pushed the skuznets/pki-csr branch 2 times, most recently from e7ce332 to 3785020 Compare December 1, 2023 19:34
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
@stevekuznetsov stevekuznetsov force-pushed the skuznets/pki-csr branch 5 times, most recently from a15269b to a845102 Compare December 2, 2023 18:08
@openshift-ci openshift-ci bot added the area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release label Dec 2, 2023
@stevekuznetsov stevekuznetsov force-pushed the skuznets/pki-csr branch 2 times, most recently from 8a64c99 to d70aba9 Compare December 2, 2023 20:24
@stevekuznetsov stevekuznetsov force-pushed the skuznets/pki-csr branch 2 times, most recently from ed82750 to 9d76262 Compare December 4, 2023 01:50
In order to acquire break-glass credentials, end users will not have
access to the management plane from which they can read certificates.
Instead, we expect them to create (by proxy) a CertificateSigningRequest
that we will sign, if it is approved.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Copy link
Contributor

@csrwng csrwng left a comment

Choose a reason for hiding this comment

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

Some initial comments

@@ -0,0 +1,185 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

I would at least add a comment saying where this came from

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
@stevekuznetsov
Copy link
Contributor Author

@csrwng thanks for the review - I'd like to hear from the client-go folks if there's a CA library I should use instead of pulling in that bit from k8s, but this is ready otherwise. Worst case, we can un-copy that in a follow-up.

@openshift-ci openshift-ci bot added the area/documentation Indicates the PR includes changes for documentation label Dec 4, 2023
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
@stevekuznetsov
Copy link
Contributor Author

/rtest

@stevekuznetsov
Copy link
Contributor Author

/retest

1 similar comment
@stevekuznetsov
Copy link
Contributor Author

/retest

@sjenning
Copy link
Contributor

sjenning commented Dec 8, 2023

/approve
/lgtm
/retest-required

Lets try to get this in before the branch

Branching already happened 👎

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

openshift-ci bot commented Dec 8, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sjenning, stevekuznetsov

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 8, 2023
@stevekuznetsov stevekuznetsov changed the title HOSTEDCP-1256: control-plane-pki-operator: add a CSR flow for break-glass creds HOSTEDCP-1257: control-plane-pki-operator: add a CSR flow for break-glass creds Dec 8, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Dec 8, 2023

@stevekuznetsov: This pull request references HOSTEDCP-1257 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.16.0" version, but no target version was set.

In response to this:

In order to acquire break-glass credentials, end users will not have access to the management plane from which they can read certificates. Instead, we expect them to create (by proxy) a CertificateSigningRequest that we will sign, if it is approved.

/cc @sjenning @csrwng @enxebre

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.

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 6315b72 and 2 for PR HEAD a1513fa in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD bcb3e90 and 1 for PR HEAD a1513fa in total

Copy link
Contributor

openshift-ci bot commented Dec 11, 2023

@stevekuznetsov: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-ibmcloud-iks a1513fa link false /test e2e-ibmcloud-iks
ci/prow/e2e-ibmcloud-roks a1513fa link false /test e2e-ibmcloud-roks

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-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 0952c61 and 0 for PR HEAD a1513fa in total

@openshift-merge-bot openshift-merge-bot bot merged commit 0f7c8c4 into openshift:main Dec 12, 2023
12 of 14 checks passed
@openshift-bot
Copy link

[ART PR BUILD NOTIFIER]

This PR has been included in build ose-hypershift-container-v4.16.0-202312121005.p0.g0f7c8c4.assembly.stream for distgit hypershift.
All builds following this will include this PR.

@stevekuznetsov
Copy link
Contributor Author

/cherry-pick release-4.15

@openshift-cherrypick-robot

@stevekuznetsov: new pull request created: #3324

In response to this:

/cherry-pick release-4.15

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.

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. area/ci-tooling Indicates the PR includes changes for CI or tooling area/cli Indicates the PR includes changes for CLI area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release area/documentation Indicates the PR includes changes for documentation area/hypershift-operator Indicates the PR includes changes for the hypershift operator and API - outside an OCP release area/testing Indicates the PR includes changes for e2e testing jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants