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

Add option allowed_domains_template enabling identity templating for issuing PKI certs #8509

Merged
merged 1 commit into from
Jul 8, 2020
Merged

Add option allowed_domains_template enabling identity templating for issuing PKI certs #8509

merged 1 commit into from
Jul 8, 2020

Conversation

andrejvanderzee
Copy link
Contributor

Implementation of identity templating when issuing a PKI cert using the exported sdk/framework merged in #8088

Duplicate of #6558

Similar to #7548

@andrejvanderzee andrejvanderzee changed the title Added option allowed_domains_template enabling identity templating for issuing PKI Added option allowed_domains_template enabling identity templating for issuing PKI certs Mar 9, 2020
@andrejvanderzee
Copy link
Contributor Author

@jefferai Any chance merging the long-awaited closure of security hole of spoofing CNs in issuing x509 certificates?

@tyrannosaurus-becks
Copy link
Contributor

Hi! Thanks for submitting this pull request.

I notice there are some test failures that appear related:

=== Errors
builtin/logical/pki/cert_util_test.go:149:35: not enough arguments in call to generateCreationBundle
	have (*backend, *inputBundle, nil, nil)
	want (*backend, *logical.Request, *inputBundle, *certutil.CAInfoBundle, *x509.CertificateRequest)
builtin/logical/pki/cert_util_test.go:181:35: not enough arguments in call to generateCreationBundle
	have (*backend, *inputBundle, nil, nil)
	want (*backend, *logical.Request, *inputBundle, *certutil.CAInfoBundle, *x509.CertificateRequest)

Happy to take a closer look after the tests are passing.

@qk4l
Copy link
Contributor

qk4l commented May 19, 2020

@andrejvanderzee , thank you for non stoping decision in implementation this features. As I've counted it's third PR and I hope the last one. =)

Could you please provide status info, if you have time to finish it, so we all can finally use this must-have feature?

Thanks again for you work.

@andrejvanderzee
Copy link
Contributor Author

@qk4l Thanks, let me fix the comments today.

@andrejvanderzee
Copy link
Contributor Author

Hi @qk4l and @tyrannosaurus-becks I have pushed fixes for the failing test.

Now test-go-race is failing on the new raft storage. That is not related to this PR I assume?

@andrejvanderzee andrejvanderzee changed the title Added option allowed_domains_template enabling identity templating for issuing PKI certs Add option allowed_domains_template enabling identity templating for issuing PKI certs May 19, 2020
@andrejvanderzee
Copy link
Contributor Author

Minimized the PR and pushed again...

@andrejvanderzee
Copy link
Contributor Author

Hi @qk4l and @tyrannosaurus-becks any update on this MR?

@ncabatoff
Copy link
Collaborator

Thank you for working on this feature, it is clearly in high demand. We're sorry it took so long to come to a consensus internally on how to proceed, but we finally have. As you may be aware, there are currently 2 open PRs trying to implement identity templating for PKI, of which yours is one: #7216 and #8509. It would be great if you would coordinate amongst yourselves to see who has the time and inclination to move forward with the proposal.

The proposal:

Other requirements:

  • There need to be tests that exercise the new behaviour; there may be other tests as well, but there should be at least one that actually exercises the full behaviour, i.e. create a role with allowed_domains_template=true, then try to generate certs with that role that rely on the expanded template and cover both the happy path (e.g. CN in the cert request matches expanded allowed_domains) and the less happy paths. TestBackend_URI_SANs is a decent example of the pattern we have in mind.
  • Use the framework method PopulateIdentityTemplate.

Not a strict requirement but a suggestion: limit the PR to allowed_domains. #7216 includes templating for allowed_uri_sans. This isn't a deal breaker, but the more narrowly focused the PR, the easier it will be to get it approved. We would prefer to see allowed_uri_sans handled in a separate PR (in the same way, with a new allowed_uri_sans_template role option.)

@andrejvanderzee
Copy link
Contributor Author

@ncabatoff Sorry for the delay it was a busy time for me.

Today I was ably to implement the requirements that you have sent in your last post. Please let me know if something is still missing or not according to standards.

Thank you.

@andrejvanderzee
Copy link
Contributor Author

Hi @ncabatoff @qk4l @tyrannosaurus-becks
Any update on this MR?

@andrejvanderzee
Copy link
Contributor Author

@ncabatoff I have added the two testcases and resolved the conversation.

@ncabatoff ncabatoff added this to the 1.5.1 milestone Jul 8, 2020
@ncabatoff ncabatoff merged commit d1f1e4b into hashicorp:master Jul 8, 2020
@ncabatoff
Copy link
Collaborator

Thanks again for the PR and your patience.

@andrejvanderzee
Copy link
Contributor Author

andrejvanderzee commented Jul 8, 2020

Thank you all, this PR has grown a long beard ;-)

@andrejvanderzee andrejvanderzee deleted the allow_id_templating_for_issuing_pki_cert branch July 8, 2020 20:21
@qk4l
Copy link
Contributor

qk4l commented Jul 15, 2020

I've noticed that this regex force to use only one pure variable. Additional domain suffices or other variables is not allowed.

Is it a feature or bug?
I suggest to remove this restriction.

What do you think?

@andrejvanderzee
Copy link
Contributor Author

I've noticed that this regex force to use only one pure variable. Additional domain suffices or other variables is not allowed.

Is it a feature or bug?
I suggest to remove this restriction.

What do you think?

Yes I think that makes sense. Its easy to add a testcase for your suggestion. I can implement it this week or if you have time you could add it, either way fine with me!

@danielpops
Copy link

I'm so happy that this feature is merged!! Thanks so much to everyone that worked on this!

@qk4l
Copy link
Contributor

qk4l commented Jul 17, 2020

I can implement it this week or if you have time you could add it, either way fine with me!

I did it in #9498

andaley pushed a commit that referenced this pull request Jul 17, 2020
calvn pushed a commit that referenced this pull request Aug 17, 2020
calvn pushed a commit that referenced this pull request Aug 17, 2020
calvn added a commit that referenced this pull request Aug 17, 2020
calvn added a commit that referenced this pull request Aug 17, 2020
catsby added a commit that referenced this pull request Aug 18, 2020
* master:
  Add a section to the MySQL secrets plugin docs about x509 (#9757)
  Update documentation for MySQL Secrets Engine (#9671)
  Conditionally overwrite TLS parameters for MySQL secrets engine (#9729)
  Correctly mark Cassandra as not supporting static roles (#9750)
  changelog++
  pki: Allow to use not only one variable during templating in allowed_domains #8509 (#9498)
  agent/templates: update consul-template to v0.25.1 (#9626)
  Restoring the example policies for blocking sha1 (#9677)
  changelog++
  changelog++
  Document the new SSH signing algorithm option. (#9197)
  CHANGELOG-+
  CHANGELOG++
  Trail of bits 018 (#9674)
pbohman added a commit to pbohman/vault that referenced this pull request Oct 16, 2021
Enables identity templating for the allowed_uri_sans field in PKI cert roles.

Implemented as suggested in hashicorp#8509
schultz-is pushed a commit that referenced this pull request Dec 15, 2021
* Add allowed_uri_sans_template

Enables identity templating for the allowed_uri_sans field in PKI cert roles.

Implemented as suggested in #8509

* changelog++

* Update docs with URI SAN templating
heppu pushed a commit to heppu/vault that referenced this pull request Jan 13, 2022
* Add allowed_uri_sans_template

Enables identity templating for the allowed_uri_sans field in PKI cert roles.

Implemented as suggested in hashicorp#8509

* changelog++

* Update docs with URI SAN templating
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants