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

New feature: client's certificate-based authentication to Infoblox NIOS server #2841

Closed

Conversation

skudriavtsev
Copy link
Contributor

Description

This PR contains changes for a new feature: client's certificate authentication to Infoblox NIOS server. And some bugfixes as well, including the fix for the issue #2198

Fixes #2198

Checklist

  • Unit tests updated
  • End user documentation updated

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 22, 2022
@k8s-ci-robot k8s-ci-robot requested review from njuettner and Raffo June 22, 2022 20:29
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: skudriavtsev
To complete the pull request process, please assign seanmalloy after the PR has been reviewed.
You can assign the PR to them by writing /assign @seanmalloy in a comment when ready.

The full list of commands accepted by this bot can be found 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

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 22, 2022
@skudriavtsev skudriavtsev changed the title Merge branch master into client-cert-auth New feature: client's certificate-based authentication to InfobloxNIOS server Jun 22, 2022
@skudriavtsev skudriavtsev changed the title New feature: client's certificate-based authentication to InfobloxNIOS server New feature: client's certificate-based authentication to Infoblox NIOS server Jun 22, 2022
@skudriavtsev
Copy link
Contributor Author

By the way, I would like to put some example YAML-deployment files for Infoblox provider and I found no separate directory for that. Probably I missed something in the project repository's rules ...

To the reviewers: which place of the repository should I put the example files in?

@ranjishmp
Copy link

Hi @Raffo / @njuettner, Can you please review this PR and share your comments ?

* TestInfobloxRecords and TestInfobloxRecordsReverse tests performed the
  same actions. To reduce the amount of test-logic, merged them into one
  table-driven test.

* Added comments for the test function and for each respective test case.
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 6, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 6, 2022
@ranjishmp
Copy link

Hi @Raffo / @njuettner, it will be really great if you can provide your review comments

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 18, 2022
@k8s-ci-robot
Copy link
Contributor

@skudriavtsev: PR needs rebase.

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.

@ranjishmp
Copy link

@skudriavtsev Please rebase the PR

Copy link
Contributor

@alebedev87 alebedev87 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @skudriavtsev !
I left some comments/questions, hope they'll be helpful.
Didn't look at the unit test part yet, will do later after my questions are clarified.

@@ -251,11 +253,13 @@ var defaultConfig = &Config{
AkamaiEdgercPath: "",
InfobloxGridHost: "",
InfobloxWapiPort: 443,
InfobloxWapiUsername: "admin",
Copy link
Contributor

Choose a reason for hiding this comment

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

This may break the existing configurations. I agree that empty user would be more generic choice at the very beginning but admin seems to be a reasonable default.

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 makes not a great sense with an empty password. But need to think of it more, this is one of the controversial points.

Comment on lines +69 to +70
if cfg.InfobloxWapiPassword == "" && cfg.InfobloxClientKey == "" && cfg.InfobloxClientCert == "" {
return errors.New("neither Infoblox WAPI password nor paths to public/private parts of TLS client certificate specified")
Copy link
Contributor

Choose a reason for hiding this comment

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

This condition allows having client certificate without the key or the other way around: client key without certificate. I think we want both parts for the client certificate auth if the password is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right.

Comment on lines +221 to +223
} else {
return nil, fmt.Errorf("neither client-certificate nor username and password are specified for authentication to Infoblox NIOS server")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is redundant, the config validation already checked this in main.go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, just one more over-insurance. I will remove it.

authMethodCert bool
)
if strings.Trim(ibStartupCfg.View, " \a\b\t\n\r\f\v") == "" {
return nil, fmt.Errorf("non-empty DNS view's name is required")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the DNS view is now required? It was working without it even when ibclient version 2 was already in use.

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 mostly not about the default value. It is about the case when a user specifies formally non-empty string which actually contains no visible characters (ex. only spaces as a result of incorrect work of automation scripts). Treat it as over-insurance :-)

For now, let's leave the default DNS view as 'default'. Under discussion, see below.

@@ -271,28 +325,38 @@ func (p *ProviderConfig) Records(ctx context.Context) (endpoints []*endpoint.End
// example: 10.196.38.0/24 becomes 38.196.10.in-addr.arpa
arpaZone, err := transform.ReverseDomainName(zone.Fqdn)
if err == nil {
var resP []ibclient.RecordPTR
var resPtrStatic, resPtrDynamic []ibclient.RecordPTR
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Why are we filtering SYSTEM PTR records?
  2. If we do some filtering why do we care for DYNAMIC records? can they even be created by ExternalDNS?
  3. Why don't we do the similar filtering (by the record creator) for the other record types (A, CNAME)?

@@ -546,11 +631,26 @@ func (p *ProviderConfig) recordSet(ep *endpoint.Endpoint, getObject bool, target
obj.PtrdName = ep.DNSName
obj.Ipv4Addr = ep.Targets[targetIndex]
obj.View = p.view
sf := map[string]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

What does sf stand for? qp used in ther other parts of the PR looks more intuitive to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

qp = query parameters
sf = search fields, actually a part of QP.

Comment on lines +747 to +750
expTypeA := ibclient.NewEmptyRecordA().ObjectType()
expTypeTXT := ibclient.NewEmptyRecordTXT().ObjectType()
expTypePTR := ibclient.NewEmptyRecordPTR().ObjectType()
expTypeCNAME := ibclient.NewEmptyRecordCNAME().ObjectType()
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't make much sense to create those variable for each for loop iteration. I think that they are better to be defined in const section at the very top of the file.

Copy link
Contributor Author

@skudriavtsev skudriavtsev Oct 6, 2022

Choose a reason for hiding this comment

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

It is fine (better) to move them out of loops but they cannot be easily defined as constants.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes true, they are computed at runtime, so they cannot be constants. var section would be ok too, my thought was to move avoid their creation at each iteration.

expTypePTR := ibclient.NewEmptyRecordPTR().ObjectType()
expTypeCNAME := ibclient.NewEmptyRecordCNAME().ObjectType()
actType := recordSet.obj.ObjectType()
if actType == expTypeA {
Copy link
Contributor

Choose a reason for hiding this comment

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

More go idiomatic would be to replace these if/elses with a switch.

@@ -16,6 +16,8 @@ export WAPI_USERNAME=admin
export WAPI_PASSWORD=infoblox
```

**Warning**: Grid's Cloud platform member is not supported yet as a target host to be used by eDNS plugin.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
**Warning**: Grid's Cloud platform member is not supported yet as a target host to be used by eDNS plugin.
**Warning**: Grid's Cloud platform member is not supported yet as a target host to be used by ExternalDNS plugin.

Copy link
Contributor Author

@skudriavtsev skudriavtsev Oct 6, 2022

Choose a reason for hiding this comment

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

agree

Now external-dns will manage PTR records for you.

**Important note 1**: you may expect that the reverse-mapping zone must be in the
form of a subdomain of the 'in-addr.arpa' domain, but in case of eDNS's Infoblox provider and
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
form of a subdomain of the 'in-addr.arpa' domain, but in case of eDNS's Infoblox provider and
form of a subdomain of the 'in-addr.arpa' domain, but in case of ExternalDNS's Infoblox provider and

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree

@skudriavtsev
Copy link
Contributor Author

skudriavtsev commented Oct 6, 2022

@alebedev87, thank you for your review, I will address the comments but today I am going to split this PR into 2-3 separate PRs instead of re-basing this one. That is why I just answered 'agree' instead of just accepting your proposals. I will update this PR with exact links.

P.S.: I guess, I will add more comments to the code.

@skudriavtsev
Copy link
Contributor Author

replaced by new PRs: #3067 and skudriavtsev#4 (which will be rebased to the original repo after the 1-st PR will be merged)

@ranjishmp ranjishmp mentioned this pull request Oct 18, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ExternalDNS deleting and then creating records. Constantly. Infoblox
5 participants