Skip to content

Certificate Signing Request Issuer CA#4064

Merged
jetstack-bot merged 11 commits intocert-manager:masterfrom
JoshVanL:certificate-request-issuer-ca
May 28, 2021
Merged

Certificate Signing Request Issuer CA#4064
jetstack-bot merged 11 commits intocert-manager:masterfrom
JoshVanL:certificate-request-issuer-ca

Conversation

@JoshVanL
Copy link
Copy Markdown
Contributor

@JoshVanL JoshVanL commented May 26, 2021

What this PR does / why we need it:
This PR adds an optional CertificateSigningRequest CA issuer. The controller is only enabled if it is explicitly done so via the --feature-gates flag (i.e. --feature-gates=ExperimentalCertificateSigningRequestControllers=true)

This begins the work to integrating kubernetes CertificateSigningRequests as part of cert-manager. (ref #3646).

Users who request a certificate referencing a namespaced issuer, must have permissions to do so in the following form:

group: cert-manager.io
resource: signers
verb: reference
namespace: <referenced signer namespace>
name: <either the name of the signer or '*' for all signer names in that namespace>

A SubjectAccessReview is performed during processing to check whether the user has sufficient permissions to reference the Issuer encoded into the signer name.

Special notes for your reviewer:

This work is based on the design in #3646

Release note:

Adds an option for a Kubernetes CertificateSigningRequest controller to implement the CA Issuer.

/cc @munnerz

JoshVanL added 6 commits May 27, 2021 00:06
Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
controller

Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
CertificateSigningRequersts Issuers

Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
@jetstack-bot jetstack-bot requested a review from munnerz May 26, 2021 23:42
@jetstack-bot jetstack-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. area/api Indicates a PR directly modifies the 'pkg/apis' directory area/deploy Indicates a PR modifies deployment configuration area/testing Issues relating to testing approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 26, 2021
@JoshVanL
Copy link
Copy Markdown
Contributor Author

flake
/retest

@james-w james-w added this to the v1.4 milestone May 27, 2021
@JoshVanL JoshVanL added the kind/feature Categorizes issue or PR as related to a new feature. label May 27, 2021
@jetstack-bot jetstack-bot removed the needs-kind Indicates a PR lacks a `kind/foo` label and requires one. label May 27, 2021
JoshVanL added 2 commits May 27, 2021 10:49
Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
@irbekrm
Copy link
Copy Markdown
Contributor

irbekrm commented May 27, 2021

/test pull-cert-manager-e2e-v1-21

Copy link
Copy Markdown
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

a few comments from me; a lot of these are small but there are a couple of bigger ones.

as this is quite a big PR[1], I can't be fully confident that I've been over everything - a second set of eyes would be good here I think.

[1] not a criticism; it's hard to imagine how this could have been cut down much.

// +groupName=experimental.cert-manager.io
// +groupGoName=Experimental

// Package certmanager is the internal version of the API.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: this doc comment is incorrect, I think?

Suggested change
// Package certmanager is the internal version of the API.
// Package experimental ...

func BuildKeyUsagesKube(usages []certificatesv1.KeyUsage) (ku x509.KeyUsage, eku []x509.ExtKeyUsage, err error) {
var unk []certificatesv1.KeyUsage
if len(usages) == 0 {
usages = []certificatesv1.KeyUsage{certificatesv1.UsageDigitalSignature, certificatesv1.UsageKeyEncipherment}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: should these default values come from https://github.com/jetstack/cert-manager/blob/a80198c03d108e4ceb7e5aceb0f2fd78be5db39d/pkg/apis/certmanager/v1/types.go#L203?

(I recognise that will require converting a certmangerv1.KeyUsage to a certificatesv1.KeyUsage, but I think it'd be good to re-use that function)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understand the intention with reusing this function. We are using a separate API group and are different types.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Default cert-manager key usages for certificates" is a useful concept and if we're going to have it as a concept we might as well have one place to change it rather than multiple places where we can forget one of them. I suppose we'd have, say, in pseudocode:

func DefaultKeyUsages() []x509.KeyUsage

in pkg/internal/ somewhere. I don't think it's required for this PR to be merged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let's leave this for now. We can always add the Default to the API at a later date.

Copy link
Copy Markdown
Contributor

@irbekrm irbekrm left a comment

Choose a reason for hiding this comment

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

Looks good to me- I have read through the code and ran the tests.
I've added a couple nits, but generally happy to approve.

Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
@JoshVanL
Copy link
Copy Markdown
Contributor Author

Thanks @SgtCoDFish @irbekrm

I have addressed your comments in the latest commit or responded. Good for another review and (hopefully) merge 🙂

@JoshVanL
Copy link
Copy Markdown
Contributor Author

/assign @irbekrm @SgtCoDFish

Copy link
Copy Markdown
Contributor

@irbekrm irbekrm left a comment

Choose a reason for hiding this comment

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

Looks good to me- I could have spent more time actually trying it out, but I guess since it's an experimental controller it'd be easier to change things later.

Copy link
Copy Markdown
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

just one test looks incorrect to me

Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
Copy link
Copy Markdown
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

one style suggestion from me, but non-blocking

Comment on lines +43 to +70
switch len(signerNameSplit) {
case 1:
return SignerIssuerRef{
Namespace: "",
Name: signerNameSplit[0],
Type: signerTypeSplit[0],
Group: signerTypeSplit[1],
}, true

default:
// ClusterIssuers do not have Namespaces
if signerTypeSplit[0] == "clusterissuers" {
return SignerIssuerRef{
Namespace: "",
Name: strings.Join(signerNameSplit[0:], "."),
Type: signerTypeSplit[0],
Group: signerTypeSplit[1],
}, true
}

// Non Cluster Scoped issuers always have Namespaces
return SignerIssuerRef{
Namespace: signerNameSplit[0],
Name: strings.Join(signerNameSplit[1:], "."),
Type: signerTypeSplit[0],
Group: signerTypeSplit[1],
}, true
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good spot on the clusterissuers special case!

suggestion (non-blocking): I know this is splitting hairs a little, but would this be better as an if statement? A switch with a single case and a default doesn't feel right; at the very least, we can save a level of indentation here.

Suggested change
switch len(signerNameSplit) {
case 1:
return SignerIssuerRef{
Namespace: "",
Name: signerNameSplit[0],
Type: signerTypeSplit[0],
Group: signerTypeSplit[1],
}, true
default:
// ClusterIssuers do not have Namespaces
if signerTypeSplit[0] == "clusterissuers" {
return SignerIssuerRef{
Namespace: "",
Name: strings.Join(signerNameSplit[0:], "."),
Type: signerTypeSplit[0],
Group: signerTypeSplit[1],
}, true
}
// Non Cluster Scoped issuers always have Namespaces
return SignerIssuerRef{
Namespace: signerNameSplit[0],
Name: strings.Join(signerNameSplit[1:], "."),
Type: signerTypeSplit[0],
Group: signerTypeSplit[1],
}, true
}
if len(signerNameSplit) == 1 {
return SignerIssuerRef{
Namespace: "",
Name: signerNameSplit[0],
Type: signerTypeSplit[0],
Group: signerTypeSplit[1],
}, true
}
// ClusterIssuers do not have Namespaces
if signerTypeSplit[0] == "clusterissuers" {
return SignerIssuerRef{
Namespace: "",
Name: strings.Join(signerNameSplit[0:], "."),
Type: signerTypeSplit[0],
Group: signerTypeSplit[1],
}, true
}
// Non Cluster Scoped issuers always have Namespaces
return SignerIssuerRef{
Namespace: signerNameSplit[0],
Name: strings.Join(signerNameSplit[1:], "."),
Type: signerTypeSplit[0],
Group: signerTypeSplit[1],
}, true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm a big proponent for switch statements personally 🤷

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Happy to change it to an if statement though.

Signed-off-by: joshvanl <vleeuwenjoshua@gmail.com>
Copy link
Copy Markdown
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label May 28, 2021
@jetstack-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: irbekrm, JoshVanL, SgtCoDFish

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [JoshVanL,SgtCoDFish,irbekrm]

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

@SgtCoDFish
Copy link
Copy Markdown
Member

/test pull-cert-manager-e2e-v1-21

@jetstack-bot jetstack-bot merged commit 528305b into cert-manager:master May 28, 2021
@jetstack-bot
Copy link
Copy Markdown
Contributor

@JoshVanL: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-cert-manager-e2e-v1-21 36bd7a4 link /test pull-cert-manager-e2e-v1-21

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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.

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/api Indicates a PR directly modifies the 'pkg/apis' directory area/deploy Indicates a PR modifies deployment configuration area/testing Issues relating to testing dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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