-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix sudo paths missing from OpenAPI and docs #21772
Changes from all commits
01f87c9
f7ca560
64530c2
ed8edc0
b4244c4
22b66de
bbe23bd
c1b1fb6
651bbae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
core: Fix OpenAPI representation and `-output-policy` recognition of some non-standard sudo paths | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ package vault | |
import ( | ||
"context" | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"path" | ||
"reflect" | ||
|
@@ -2325,12 +2326,12 @@ func TestTokenStore_HandleRequest_RevokeOrphan(t *testing.T) { | |
testMakeServiceTokenViaBackend(t, ts, root, "child", "60s", []string{"root", "foo"}) | ||
testMakeServiceTokenViaBackend(t, ts, "child", "sub-child", "50s", []string{"foo"}) | ||
|
||
req := logical.TestRequest(t, logical.UpdateOperation, "revoke-orphan") | ||
req := logical.TestRequest(t, logical.UpdateOperation, "auth/token/revoke-orphan") | ||
req.Data = map[string]interface{}{ | ||
"token": "child", | ||
} | ||
req.ClientToken = root | ||
resp, err := ts.HandleRequest(namespace.RootContext(nil), req) | ||
resp, err := c.HandleRequest(namespace.RootContext(nil), req) | ||
if err != nil || (resp != nil && resp.IsError()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to reviewer: Since the common sudo-enforcing logic is part of the Core, we need to fix tests which care about the sudo behaviour, and were previously slipping requests directly to the backend, bypassing the Core, to make the request via the proper layers. This test is the case where the requesting token does have sudo rights, testing the "allowed" case, and the next test below is testing the "denied" case. |
||
t.Fatalf("err: %v\nresp: %#v", err, resp) | ||
} | ||
|
@@ -2384,14 +2385,14 @@ func TestTokenStore_HandleRequest_RevokeOrphan_NonRoot(t *testing.T) { | |
t.Fatalf("bad: %v", out) | ||
} | ||
|
||
req := logical.TestRequest(t, logical.UpdateOperation, "revoke-orphan") | ||
req := logical.TestRequest(t, logical.UpdateOperation, "auth/token/revoke-orphan") | ||
req.Data = map[string]interface{}{ | ||
"token": "child", | ||
} | ||
req.ClientToken = "child" | ||
resp, err := ts.HandleRequest(namespace.RootContext(nil), req) | ||
if err != logical.ErrInvalidRequest { | ||
t.Fatalf("did not get error when non-root revoking itself with orphan flag; resp is %#v", resp) | ||
resp, err := c.HandleRequest(namespace.RootContext(nil), req) | ||
if !errors.Is(err, logical.ErrPermissionDenied) { | ||
t.Fatalf("did not get expected error when non-root revoking itself with orphan flag; resp is %#v; err is %#v", resp, err) | ||
} | ||
|
||
time.Sleep(200 * time.Millisecond) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -799,17 +799,18 @@ authenticated user. | |
## Root protected API endpoints | ||
|
||
~> **Note:** Vault treats the HTTP POST and PUT verbs as equivalent, so for each mention | ||
of POST in the table above, PUT may also be used. Vault uses the non-standard LIST HTTP | ||
of POST in the table below, PUT may also be used. Vault uses the non-standard LIST HTTP | ||
verb, but also allows list requests to be made using the GET verb along with `?list=true` | ||
as a query parameter, so for each mention of LIST in the table above, GET with `?list=true` | ||
may also be used. | ||
|
||
The following paths requires a root token or `sudo` capability in the policy: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to reviewer: Only one line in the table has semantic changes, please use a whitespace-ignoring diff mode to see what is really going on: https://github.com/hashicorp/vault/pull/21772/files?diff=unified&w=1#diff-cc6f6f882b5e1952856decc6cefb2caf95af3ead2ece1d3b3cd1073d92c2625e There are other factual inaccuracies in this table (see issue #20780), but I've refrained from expanding the scope of this PR beyond the specific endpoints I was making code changes to. |
||
| Path | HTTP verb | Description | | ||
| -------------------------------------------------------------------------------------------------------------------------------------------------------| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|---------------------------------------------------------------------------------------------------------------------| | ||
| [auth/token/accessors](/vault/api-docs/auth/token#list-accessors) | LIST | List token accessors for all current Vault service tokens | | ||
| [auth/token/create](/vault/api-docs/auth/token#create-token) | POST | Create a periodic or an orphan token (`period` or `no_parent`) option | | ||
| [auth/token/revoke-orphan](/vault/api-docs/auth/token#revoke-token-and-orphan-children) | POST | Revoke a token but not its child tokens, which will be orphaned | | ||
| [pki/root](/vault/api-docs/secret/pki#delete-all-issuers-and-keys) | DELETE | Delete the current CA key ([pki secrets engine](/vault/docs/secrets/pki)) | | ||
| [pki/root/sign-self-issued](/vault/api-docs/secret/pki#sign-self-issued) | POST | Use the configured CA certificate to sign a self-issued certificate ([pki secrets engine](/vault/docs/secrets/pki)) | | ||
| [sys/audit](/vault/api-docs/system/audit) | GET | List enabled audit devices | | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewer:
The prior definition of
revoke-orphan/*
is just plain wrong, so it is fixed.The prior definition of
accessors*
technically works, because it uses a needless wildcard - that change is just for precision.