mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-31 18:48:08 +00:00
OpenAPI generic_mount_paths follow-up (#18663)
* OpenAPI `generic_mount_paths` follow-up An incremental improvement within larger context discussed in #18560. * Following the revert in #18617, re-introduce the change from `{mountPath}` to `{<path-of-mount>_mount_path}`; this is needed, as otherwise paths from multiple plugins would clash - e.g. almost every auth method would provide a conflicting definition for `auth/{mountPath}/login`, and the last one written into the map would win. * Move the half of the functionality that was in `sdk/framework/` to `vault/logical_system.go` with the rest; this is needed, as `sdk/framework/` gets compiled in to externally built plugins, and therefore there may be version skew between it and the Vault main code. Implementing the `generic_mount_paths` feature entirely on one side of this boundary frees us from problems caused by this. * Update the special exception that recognizes `system` and `identity` as singleton mounts to also include the other two singleton mounts, `cubbyhole` and `auth/token`. * Include a comment that documents to restricted circumstances in which the `generic_mount_paths` option makes sense to use: // Note that for this to actually be useful, you have to be using it with // a Vault instance in which you have mounted one of each secrets engine // and auth method of types you are interested in, at paths which identify // their type, and for the KV secrets engine you will probably want to // mount separate kv-v1 and kv-v2 mounts to include the documentation for // each of those APIs. * Fix tests Also remove comment "// TODO update after kv repo update" which was added 4 years ago in #5687 - the implied update has not happened. * Add changelog * Update 18663.txt
This commit is contained in:
@@ -215,9 +215,9 @@ var (
|
||||
)
|
||||
|
||||
// documentPaths parses all paths in a framework.Backend into OpenAPI paths.
|
||||
func documentPaths(backend *Backend, requestResponsePrefix string, genericMountPaths bool, doc *OASDocument) error {
|
||||
func documentPaths(backend *Backend, requestResponsePrefix string, doc *OASDocument) error {
|
||||
for _, p := range backend.Paths {
|
||||
if err := documentPath(p, backend.SpecialPaths(), requestResponsePrefix, genericMountPaths, backend.BackendType, doc); err != nil {
|
||||
if err := documentPath(p, backend.SpecialPaths(), requestResponsePrefix, backend.BackendType, doc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -226,7 +226,7 @@ func documentPaths(backend *Backend, requestResponsePrefix string, genericMountP
|
||||
}
|
||||
|
||||
// documentPath parses a framework.Path into one or more OpenAPI paths.
|
||||
func documentPath(p *Path, specialPaths *logical.Paths, requestResponsePrefix string, genericMountPaths bool, backendType logical.BackendType, doc *OASDocument) error {
|
||||
func documentPath(p *Path, specialPaths *logical.Paths, requestResponsePrefix string, backendType logical.BackendType, doc *OASDocument) error {
|
||||
var sudoPaths []string
|
||||
var unauthPaths []string
|
||||
|
||||
@@ -265,21 +265,6 @@ func documentPath(p *Path, specialPaths *logical.Paths, requestResponsePrefix st
|
||||
// Body fields will be added to individual operations.
|
||||
pathFields, bodyFields := splitFields(p.Fields, path)
|
||||
|
||||
if genericMountPaths && requestResponsePrefix != "system" && requestResponsePrefix != "identity" {
|
||||
// Add mount path as a parameter
|
||||
p := OASParameter{
|
||||
Name: "mountPath",
|
||||
Description: "Path that the backend was mounted at",
|
||||
In: "path",
|
||||
Schema: &OASSchema{
|
||||
Type: "string",
|
||||
},
|
||||
Required: true,
|
||||
}
|
||||
|
||||
pi.Parameters = append(pi.Parameters, p)
|
||||
}
|
||||
|
||||
for name, field := range pathFields {
|
||||
location := "path"
|
||||
required := true
|
||||
|
||||
Reference in New Issue
Block a user