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

VAULT-20669: Add New Authenticated Endpoint for Version #23740

Merged

Conversation

marcboudreau
Copy link
Contributor

This PR adds a new endpoint sys/internal/ui/version which requires a Vault Token that has the read capability granted for its path. The change also adds a new rule that grants the read capability to this path in the default policy. This endpoint is used to obtain the Vault version.

This new path is being introduced to provide a guaranteed mechanism for the Vault UI to retrieve the Vault version, since the current endpoints: sys/health and sys/seal-status can have the version number redacted if the redact_version TCP listener configuration parameter is set to true.

The Vault UI will be changed to use this endpoint in a later change.

@marcboudreau marcboudreau marked this pull request as draft October 19, 2023 18:29
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Oct 19, 2023
@github-actions
Copy link

Build Results:
All builds succeeded! ✅

@github-actions
Copy link

CI Results:
All Go tests succeeded! ✅

@marcboudreau marcboudreau force-pushed the marcboudreau/VAULT-20669/add-new-ui-version-endpoint branch from 870416c to f39ddd9 Compare October 19, 2023 18:57
@marcboudreau marcboudreau added this to the 1.16.0-rc1 milestone Oct 19, 2023
@marcboudreau marcboudreau requested a review from a team October 19, 2023 19:08
@marcboudreau marcboudreau force-pushed the marcboudreau/VAULT-20669/add-new-ui-version-endpoint branch from f39ddd9 to 78ff999 Compare October 19, 2023 19:19
@marcboudreau marcboudreau marked this pull request as ready for review October 19, 2023 19:39
@marcboudreau marcboudreau requested a review from a team as a code owner October 19, 2023 19:39
@raskchanky
Copy link
Contributor

@marcboudreau Neither sys/health nor sys/seal-status are authenticated endpoints. Why does this new endpoint need to be authenticated?

@raskchanky
Copy link
Contributor

Is it worth adding a test that verifies this new endpoint outputs the right thing?

@peteski22
Copy link

peteski22 commented Oct 20, 2023

@marcboudreau Neither sys/health nor sys/seal-status are authenticated endpoints. Why does this new endpoint need to be authenticated?

@raskchanky I believe the idea is so that when the Vault platform operator has configured redaction to occur on the unauthenticated endpoints (sys/health and sys/seal-status) they will no long report 'version', this PR means there can still be a way to retrieve the version (for the UI) but you have to be logged in to get it.

We recently added this in a few PRs but the docs might explain the redaction settings better. 😄

Copy link

@peteski22 peteski22 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, but @raskchanky made a good point in a previous comment that it might be reassuring to have some tests to make sure we get what we're expecting from the endpoint.

Failing that some receipts in the PR summary to show the output? 🤷🏼

vault/logical_system.go Show resolved Hide resolved
Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathInternalUIVersion,
Summary: "Backwards compatibility is not guaranteed for this API",

Choose a reason for hiding this comment

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

❓ I wonder why we just use the same summary message for multiple internal API endpoints, do you think it would be useful to include what this endpoint is for (even if it also says that it doesn't guarantee backwards compatibility)?

@marcboudreau
Copy link
Contributor Author

Is it worth adding a test that verifies this new endpoint outputs the right thing?

The handler function only has a single branch of execution and so I don't think adding a test for the handler provides much value, however I looked at the version package and there's plenty of untested conditional branching going on there, so I'll add tests there. My thinking is that if we are confident that version.GetVersion().VersionNumber() works correctly, then we can also be confident that the pathInternalUIVersion handler will work as well.

@raskchanky
Copy link
Contributor

@peteski22 Thanks for clarifying! Makes sense.

@marcboudreau
Copy link
Contributor Author

My latest two commits add tests for the functions exported from the version package, this will give us the confidence that version.GetVersion().VersionNumber() functions correctly. In addition, a line of code inside of an if block that can never be reached has been removed.

@ccapurso
Copy link
Contributor

❓ I definitely understand the intent of moving it to an authenticated endpoint. Is there is a purpose to prefixing it with internal/ui? The version information used to be generally available in the sys/seal-status endpoint. If I understand correctly, we typically reserve internal/ui endpoints for those that may fluctuate more heavily than the general system backend APIs.

@marcboudreau
Copy link
Contributor Author

The version information is still available from the unauthenticated endpoints sys/health and sys/seal-status will continue to report the version, unless the redaction setting is used. This new endpoint is being introduced because the UI needs to retrieve the version (at least once the user is logged in) even if the UI is accessed using a listener (address and port) where the redaction setting is used.

version/version.go Show resolved Hide resolved
version/version_test.go Outdated Show resolved Hide resolved
website/content/api-docs/system/internal-ui-version.mdx Outdated Show resolved Hide resolved
Copy link
Contributor

@raskchanky raskchanky left a comment

Choose a reason for hiding this comment

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

Copy link
Contributor

@ccapurso ccapurso 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!

Marc Boudreau and others added 2 commits October 25, 2023 17:26
@marcboudreau marcboudreau merged commit 550c99a into main Oct 26, 2023
100 of 102 checks passed
@marcboudreau marcboudreau deleted the marcboudreau/VAULT-20669/add-new-ui-version-endpoint branch October 26, 2023 16:52
divyaac added a commit that referenced this pull request Mar 19, 2024
divyaac added a commit that referenced this pull request Mar 21, 2024
* VAULT-24469 use sys/seal-status instead of internal version endpoint

* Update tests and mirage handlers

* Revert "VAULT-20669: Add New Authenticated Endpoint for Version  (#23740)"

This reverts commit 550c99a.

* Readded version_test.go

* Reverted any old changes on versionlgo

---------

Co-authored-by: divyaac <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants