mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 02:28:09 +00:00 
			
		
		
		
	Fix sudo paths missing from OpenAPI and docs (#21772)
* Fix sudo paths missing from OpenAPI and docs Various sudo (a.k.a. root-protected) paths are implemented in non-standard ways, and as a result: * are not declared as x-vault-sudo in the OpenAPI spec * and as a result of that, are not included in the hardcoded patterns powering the Vault CLI `-output-policy` flag * and in some cases are missing from the table of all sudo paths in the docs too Fix these problems by: * Adding `seal` and `step-down` to the list of root paths for the system backend. They don't need to be there for enforcement, as those two special endpoints bypass the standard request handling code, but they do need to be there for the OpenAPI generator to be able to know they require sudo. The way in which those two endpoints do things differently can be observed in the code search results for `RootPrivsRequired`: https://github.com/search?q=repo%3Ahashicorp%2Fvault%20RootPrivsRequired&type=code * Fix the implementation of `auth/token/revoke-orphan` to implement endpoint sudo requirements in the standard way. Currently, it has an **incorrect** path declared in the special paths metadata, and then compensates with custom code throwing an error within the request handler function itself. * changelog * As discussed in PR, delete test which is just testing equality of a constant * Restore sudo check as requested, and add comment * Update vault/token_store.go Co-authored-by: Anton Averchenkov <84287187+averche@users.noreply.github.com> --------- Co-authored-by: Anton Averchenkov <84287187+averche@users.noreply.github.com>
This commit is contained in:
		| @@ -14,8 +14,8 @@ import ( | ||||
| // path matches that path or not (useful specifically for the paths that | ||||
| // contain templated fields.) | ||||
| var sudoPaths = map[string]*regexp.Regexp{ | ||||
| 	"/auth/token/accessors": regexp.MustCompile(`^/auth/token/accessors/?$`), | ||||
| 	// TODO /auth/token/revoke-orphan requires sudo but isn't represented as such in the OpenAPI spec | ||||
| 	"/auth/token/accessors":                         regexp.MustCompile(`^/auth/token/accessors/?$`), | ||||
| 	"/auth/token/revoke-orphan":                     regexp.MustCompile(`^/auth/token/revoke-orphan$`), | ||||
| 	"/pki/root":                                     regexp.MustCompile(`^/pki/root$`), | ||||
| 	"/pki/root/sign-self-issued":                    regexp.MustCompile(`^/pki/root/sign-self-issued$`), | ||||
| 	"/sys/audit":                                    regexp.MustCompile(`^/sys/audit$`), | ||||
| @@ -45,8 +45,8 @@ var sudoPaths = map[string]*regexp.Regexp{ | ||||
| 	"/sys/revoke-force/{prefix}":         regexp.MustCompile(`^/sys/revoke-force/.+$`), | ||||
| 	"/sys/revoke-prefix/{prefix}":        regexp.MustCompile(`^/sys/revoke-prefix/.+$`), | ||||
| 	"/sys/rotate":                        regexp.MustCompile(`^/sys/rotate$`), | ||||
| 	// TODO /sys/seal requires sudo but isn't represented as such in the OpenAPI spec | ||||
| 	// TODO /sys/step-down requires sudo but isn't represented as such in the OpenAPI spec | ||||
| 	"/sys/seal":                          regexp.MustCompile(`^/sys/seal$`), | ||||
| 	"/sys/step-down":                     regexp.MustCompile(`^/sys/step-down$`), | ||||
|  | ||||
| 	// enterprise-only paths | ||||
| 	"/sys/replication/dr/primary/secondary-token":          regexp.MustCompile(`^/sys/replication/dr/primary/secondary-token$`), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Max Bowsher
					Max Bowsher