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-12112: add openapi responses for /sys/internal endpoints #18542

Merged
merged 12 commits into from
Feb 24, 2023
3 changes: 3 additions & 0 deletions changelog/18542.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
openapi: add openapi response definitions to /sys/internal endpoints
```
142 changes: 142 additions & 0 deletions vault/logical_system_paths.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package vault

import (
"net/http"
"strings"

"github.com/hashicorp/vault/sdk/framework"
Expand Down Expand Up @@ -983,6 +984,17 @@ func (b *SystemBackend) internalPaths() []*framework.Path {
logical.ReadOperation: &framework.PathOperation{
// callback is absent because this is an unauthenticated method
Summary: "Lists enabled feature flags.",
Responses: map[int][]framework.Response{
http.StatusOK: {{
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"feature_flags": {
Type: framework.TypeCommaStringSlice,
Required: true,
},
},
}},
},
},
},
HelpSynopsis: strings.TrimSpace(sysHelp["internal-ui-feature-flags"][0]),
Expand All @@ -994,6 +1006,23 @@ func (b *SystemBackend) internalPaths() []*framework.Path {
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathInternalUIMountsRead,
Summary: "Lists all enabled and visible auth and secrets mounts.",
Responses: map[int][]framework.Response{
http.StatusOK: {{
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"secret": {
Description: "secret mounts",
Type: framework.TypeMap,
Required: true,
},
"auth": {
Description: "auth mounts",
Type: framework.TypeMap,
Required: true,
},
},
}},
},
},
},
HelpSynopsis: strings.TrimSpace(sysHelp["internal-ui-mounts"][0]),
Expand All @@ -1011,6 +1040,61 @@ func (b *SystemBackend) internalPaths() []*framework.Path {
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathInternalUIMountRead,
Summary: "Return information about the given mount.",
Responses: map[int][]framework.Response{
http.StatusOK: {{
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"type": {
Type: framework.TypeString,
Required: true,
},
"description": {
Type: framework.TypeString,
Required: true,
},
"accessor": {
Type: framework.TypeString,
Required: true,
},
"local": {
Type: framework.TypeBool,
Required: true,
},
"seal_wrap": {
Type: framework.TypeBool,
Required: true,
},
"external_entropy_access": {
Type: framework.TypeBool,
Required: true,
},
"options": {
Type: framework.TypeMap,
Required: true,
},
"uuid": {
Type: framework.TypeString,
Required: true,
},
"plugin_version": {
Type: framework.TypeString,
Required: true,
},
"running_plugin_version": {
Type: framework.TypeString,
Required: true,
},
"running_sha256": {
Type: framework.TypeString,
Required: true,
},
"path": {
Type: framework.TypeString,
Required: true,
},
},
}},
},
},
},
HelpSynopsis: strings.TrimSpace(sysHelp["internal-ui-mounts"][0]),
Expand All @@ -1022,6 +1106,17 @@ func (b *SystemBackend) internalPaths() []*framework.Path {
logical.ReadOperation: &framework.PathOperation{
Callback: pathInternalUINamespacesRead(b),
Summary: "Backwards compatibility is not guaranteed for this API",
Responses: map[int][]framework.Response{
http.StatusOK: {{
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"keys": {
Type: framework.TypeCommaStringSlice,
Description: "field is only returned if there are one or more namespaces",
},
},
}},
},
},
},
HelpSynopsis: strings.TrimSpace(sysHelp["internal-ui-namespaces"][0]),
Expand All @@ -1033,6 +1128,29 @@ func (b *SystemBackend) internalPaths() []*framework.Path {
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathInternalUIResultantACL,
Summary: "Backwards compatibility is not guaranteed for this API",
Responses: map[int][]framework.Response{
http.StatusNoContent: {{
Description: "empty response returned if no client token",
Fields: nil,
}},
http.StatusOK: {{
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"root": {
Type: framework.TypeBool,
Required: true,
},
"exact_paths": {
Type: framework.TypeMap,
Required: false,
},
"glob_paths": {
Type: framework.TypeMap,
Required: false,
},
},
}},
},
},
},
HelpSynopsis: strings.TrimSpace(sysHelp["internal-ui-resultant-acl"][0]),
Expand All @@ -1044,6 +1162,8 @@ func (b *SystemBackend) internalPaths() []*framework.Path {
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathInternalCountersRequests,
Summary: "Backwards compatibility is not guaranteed for this API",
// callback only returns errors
dhuckins marked this conversation as resolved.
Show resolved Hide resolved
Responses: nil,
},
},
HelpSynopsis: strings.TrimSpace(sysHelp["internal-counters-requests"][0]),
Expand All @@ -1055,6 +1175,17 @@ func (b *SystemBackend) internalPaths() []*framework.Path {
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathInternalCountersTokens,
Summary: "Backwards compatibility is not guaranteed for this API",
Responses: map[int][]framework.Response{
http.StatusOK: {{
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"counters": {
Type: framework.TypeMap,
Required: true,
},
},
}},
},
},
},
HelpSynopsis: strings.TrimSpace(sysHelp["internal-counters-tokens"][0]),
Expand All @@ -1066,6 +1197,17 @@ func (b *SystemBackend) internalPaths() []*framework.Path {
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathInternalCountersEntities,
Summary: "Backwards compatibility is not guaranteed for this API",
Responses: map[int][]framework.Response{
http.StatusOK: {{
Description: "OK",
Fields: map[string]*framework.FieldSchema{
"counters": {
Type: framework.TypeMap,
Required: true,
},
},
}},
},
},
},
HelpSynopsis: strings.TrimSpace(sysHelp["internal-counters-entities"][0]),
Expand Down