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

PKI - Honor header If-Modified-Since if present #16249

Conversation

Gabrielopesantos
Copy link
Contributor

No description provided.

@Gabrielopesantos
Copy link
Contributor Author

Hello @cipherboy, opened this pull request just to make sure that what we have discussed for #3190 is still valid since there seem to have been many changes in the crl endpoints.
So far, this PR has an implementation to honor the "If-Modified-Since" header, if present, in the crl and crl/pem endpoints. Feedback on it would be appreciated.

I still intended to test the implementation and also look at a possible refactoring of the patchFetch function.

@heatherezell
Copy link
Contributor

Hi @Gabrielopesantos - please don't forget to add a changelog entry too. :) Please see the contributing.md for more details.

@cipherboy cipherboy changed the title Honor header If-Modified-Since if present PKI - Honor header If-Modified-Since if present Jul 26, 2022
@cipherboy
Copy link
Contributor

Sorry @Gabrielopesantos -- I've been on vacation for a bit, I'll take a look at this week now that I'm back :)

@cipherboy cipherboy self-requested a review July 26, 2022 18:42
Copy link
Contributor

@cipherboy cipherboy left a comment

Choose a reason for hiding this comment

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

This looks great! I think you'd want to do it for pathGetIssuerCRL and perhaps pathGetRawIssuer as well? :-) You might need to store the creation time on the IssuerEntry object as well, perhaps migrating if one doesn't exist. I wouldn't do the CA if-modified-since on the default issuer (path_fetch.go).

builtin/logical/pki/path_fetch.go Outdated Show resolved Hide resolved
builtin/logical/pki/path_fetch.go Outdated Show resolved Hide resolved
Copy link
Contributor

@cipherboy cipherboy left a comment

Choose a reason for hiding this comment

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

Many thanks! I think this looks great! :-)

A few comments inline, perhaps @stevendpclark could take a look too. But I think this is ready to unmark from draft and we'll merge it.

I've think we've got some changes in the pipeline that'll probably cause merge conflicts -- would you like us to resolve those or would you like to? If we merge this sooner rather than later, we can definitely make this release and perhaps avoid some of those conflicts... :-D

Happy to write the tests if you don't want to, too. :-)

builtin/logical/pki/config_util.go Outdated Show resolved Hide resolved
builtin/logical/pki/path_fetch_issuers.go Outdated Show resolved Hide resolved
builtin/logical/pki/path_fetch_issuers.go Outdated Show resolved Hide resolved
builtin/logical/pki/path_fetch_issuers.go Outdated Show resolved Hide resolved
builtin/logical/pki/path_fetch_issuers.go Outdated Show resolved Hide resolved
builtin/logical/pki/path_fetch_issuers.go Outdated Show resolved Hide resolved
builtin/logical/pki/path_fetch_issuers.go Outdated Show resolved Hide resolved
builtin/logical/pki/storage.go Outdated Show resolved Hide resolved
builtin/logical/pki/config_util.go Outdated Show resolved Hide resolved
@Gabrielopesantos
Copy link
Contributor Author

Gabrielopesantos commented Aug 22, 2022

Ok, with this last commit I am happy with opening the pull request. I have made a small refactoring based on comments which I think is an improvement from what I had before. I think some of the stuff related to checking the header can moved from storage.go to a utils file (not sure what to call it). There is still also maybe an update in the Docs.

Regarding tests, I wouldn't minding doing them as there are still likely corner cases that I did not manually test or don't know about. However, as we might have merge conflicts and if you think we can make this release, I'm ok with other person taking from here. Let me know if there is anything else I can do regarding this PR, if not I will just come in the end to set what were your changes.

@cipherboy cipherboy force-pushed the pki/honor-header-http-if-modified-since branch from 247697b to a9cf675 Compare August 29, 2022 15:31
Gabrielopesantos and others added 13 commits August 29, 2022 11:55
For the most part, these take a SC as param, but aren't directly storage
relevant operations. Move them out of storage.go as a result.

Signed-off-by: Alexander Scheel <[email protected]>
Signed-off-by: Alexander Scheel <[email protected]>
When the default is updated, access under earlier timestamps will not
work as we're unclear if the timestamp is for this issuer or a previous
issuer. Thus, we need to invalidate the CRL and both issuers involved
(previous, next) by updating their LastModifiedTimes.

Signed-off-by: Alexander Scheel <[email protected]>
Signed-off-by: Alexander Scheel <[email protected]>
When the default issuer changes, we'll have to mark the invalidation on
PR secondary clusters, so they know to update their CRL mapping as well.
The swapped issuers will have an updated modification time (which will
eventually replicate down and thus be correct), but the CRL modification
time is cluster-local information and thus won't be replicated.

Signed-off-by: Alexander Scheel <[email protected]>
Signed-off-by: Alexander Scheel <[email protected]>
@cipherboy cipherboy force-pushed the pki/honor-header-http-if-modified-since branch from a9cf675 to aabf2c7 Compare August 29, 2022 15:58
Copy link
Contributor

@stevendpclark stevendpclark 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 nits but hardly worth keeping this from being merged.

builtin/logical/pki/util.go Outdated Show resolved Hide resolved
builtin/logical/pki/util.go Outdated Show resolved Hide resolved
builtin/logical/pki/util.go Outdated Show resolved Hide resolved
@cipherboy cipherboy marked this pull request as ready for review August 29, 2022 18:13
Signed-off-by: Alexander Scheel <[email protected]>
Copy link
Contributor

@stevendpclark stevendpclark left a comment

Choose a reason for hiding this comment

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

👍

@cipherboy
Copy link
Contributor

A few follow-up minor changes can be merged in the next PR.

Thank you @Gabrielopesantos for kicking this off and doing a lot of the work in this PR!!

@cipherboy cipherboy merged commit a805ccb into hashicorp:main Aug 29, 2022
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.

4 participants