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

openapi: Add display attributes for token/ #19399

Merged
merged 42 commits into from
Apr 6, 2023
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
857ec3f
add prefix & suffix display attributes
averche Feb 21, 2023
beed664
add DisplayAttrs to PathParameters
averche Feb 22, 2023
df763a5
add constructOperationID func
averche Feb 22, 2023
72c5c47
Fixes & comments
averche Feb 22, 2023
ce4ca4a
Add test and fix logic
averche Feb 23, 2023
fcdd2d3
fix existing test data
averche Feb 23, 2023
f3a4dbe
ommitempty
averche Feb 23, 2023
5c72769
changelog
averche Feb 23, 2023
d3e16aa
better suffix disambiguation
averche Feb 26, 2023
22a1e74
Update comment
averche Feb 26, 2023
7003717
hyphenate instead of TitleCase
averche Feb 27, 2023
4713d81
fmt
averche Feb 27, 2023
1b5afe3
User OperationVerb since Action conflicts
averche Feb 27, 2023
54ad97a
reorder vars
averche Feb 27, 2023
d038f41
openapi: Add display attributes for token/
averche Feb 28, 2023
a5da163
changelog
averche Feb 28, 2023
4f6d2f3
swap read/update
averche Feb 28, 2023
1644e43
Merge branch 'main' into ui/openapi-naming-strategy
averche Feb 28, 2023
06ba323
Merge branch 'ui/openapi-naming-strategy' into display-attributes-token
averche Mar 1, 2023
39ab2ef
rm changelog
averche Mar 1, 2023
26b144e
allow verb-only
averche Mar 1, 2023
49eda18
better comments
averche Mar 1, 2023
72c4acd
more comments, better example
averche Mar 3, 2023
d6c2a45
better name for helper
averche Mar 12, 2023
99c30f4
Merge branch 'main' into ui/openapi-naming-strategy
averche Mar 13, 2023
63422a8
Merge branch 'ui/openapi-naming-strategy' into display-attributes-token
averche Mar 21, 2023
5a88029
look-up
averche Mar 21, 2023
af41a73
allow empty multi-field suffixes
averche Mar 22, 2023
23f731d
Merge branch 'main' into ui/openapi-naming-strategy
averche Mar 23, 2023
243c898
add withoutOperationHints
averche Mar 23, 2023
d37caaa
nil check
averche Mar 23, 2023
cb5aa04
empty obj check
averche Mar 23, 2023
be2a068
Merge branch 'ui/openapi-naming-strategy' into display-attributes-token
averche Mar 29, 2023
49cd9e0
look-up-self3
averche Mar 29, 2023
7aacc2c
write -> create-or-update
averche Mar 30, 2023
f05e5e1
Merge branch 'main' into ui/openapi-naming-strategy
averche Mar 30, 2023
ed3a56d
Revert "write -> create-or-update"
averche Mar 31, 2023
0748a1a
title case response/request names
averche Apr 4, 2023
8ebef3a
Merge branch 'ui/openapi-naming-strategy' into display-attributes-token
averche Apr 4, 2023
4d60603
Merge branch 'main' into display-attributes-token
averche Apr 4, 2023
93da9a7
Merge branch 'main' into display-attributes-token
averche Apr 5, 2023
4fe1bd8
Merge branch 'main' into display-attributes-token
averche Apr 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 119 additions & 6 deletions vault/token_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,17 @@ var (
)

func (ts *TokenStore) paths() []*framework.Path {
const operationPrefixToken = "token"

p := []*framework.Path{
{
Pattern: "roles/?$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationSuffix: "roles",
},

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ListOperation: ts.tokenStoreRoleList,
},
Expand All @@ -153,6 +160,11 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "accessors/$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationSuffix: "accessors",
},

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ListOperation: ts.tokenStoreAccessorList,
},
Expand All @@ -164,6 +176,12 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "create-orphan$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "create",
OperationSuffix: "orphan",
},

Fields: map[string]*framework.FieldSchema{
"role_name": {
Type: framework.TypeString,
Expand Down Expand Up @@ -239,6 +257,12 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "create/" + framework.GenericNameRegex("role_name"),

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "create",
OperationSuffix: "against-role",
averche marked this conversation as resolved.
Show resolved Hide resolved
},

Fields: map[string]*framework.FieldSchema{
"role_name": {
Type: framework.TypeString,
Expand Down Expand Up @@ -314,6 +338,11 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "create$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "create",
},

Fields: map[string]*framework.FieldSchema{
"display_name": {
Type: framework.TypeString,
Expand Down Expand Up @@ -385,16 +414,28 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "lookup",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "look-up",
},
averche marked this conversation as resolved.
Show resolved Hide resolved

Fields: map[string]*framework.FieldSchema{
"token": {
Type: framework.TypeString,
Description: "Token to lookup (POST request body)",
},
},

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: ts.handleLookup,
logical.UpdateOperation: ts.handleLookup,
Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{
Callback: ts.handleLookup,
DisplayAttrs: &framework.DisplayAttributes{
OperationSuffix: "self3", // avoid collision with lookup-self
},
},
logical.UpdateOperation: &framework.PathOperation{
Callback: ts.handleLookup,
},
},

HelpSynopsis: strings.TrimSpace(tokenLookupHelp),
Expand All @@ -404,6 +445,12 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "lookup-accessor",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "look-up",
OperationSuffix: "accessor",
},

Fields: map[string]*framework.FieldSchema{
"accessor": {
Type: framework.TypeString,
Expand All @@ -422,16 +469,31 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "lookup-self$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "look-up",
},

Fields: map[string]*framework.FieldSchema{
"token": {
Type: framework.TypeString,
Description: "Token to look up (unused, does not need to be set)",
},
},

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.UpdateOperation: ts.handleLookupSelf,
logical.ReadOperation: ts.handleLookupSelf,
Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{
Callback: ts.handleLookupSelf,
DisplayAttrs: &framework.DisplayAttributes{
OperationSuffix: "self",
},
},
logical.UpdateOperation: &framework.PathOperation{
Callback: ts.handleLookupSelf,
DisplayAttrs: &framework.DisplayAttributes{
OperationSuffix: "self2",
averche marked this conversation as resolved.
Show resolved Hide resolved
},
},
},

HelpSynopsis: strings.TrimSpace(tokenLookupHelp),
Expand All @@ -441,6 +503,12 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "revoke-accessor",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "revoke",
OperationSuffix: "accessor",
},

Fields: map[string]*framework.FieldSchema{
"accessor": {
Type: framework.TypeString,
Expand All @@ -459,6 +527,12 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "revoke-self$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "revoke",
OperationSuffix: "self",
},

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.UpdateOperation: ts.handleRevokeSelf,
},
Expand All @@ -470,6 +544,11 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "revoke",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "revoke",
},

Fields: map[string]*framework.FieldSchema{
"token": {
Type: framework.TypeString,
Expand All @@ -488,6 +567,12 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "revoke-orphan",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "revoke",
OperationSuffix: "orphan",
},

Fields: map[string]*framework.FieldSchema{
"token": {
Type: framework.TypeString,
Expand All @@ -506,6 +591,12 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "renew-accessor",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "renew",
OperationSuffix: "accessor",
},

Fields: map[string]*framework.FieldSchema{
"accessor": {
Type: framework.TypeString,
Expand All @@ -529,6 +620,12 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "renew-self$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "renew",
OperationSuffix: "self",
},

Fields: map[string]*framework.FieldSchema{
"token": {
Type: framework.TypeString,
Expand All @@ -552,6 +649,11 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "renew",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "renew",
},

Fields: map[string]*framework.FieldSchema{
"token": {
Type: framework.TypeString,
Expand All @@ -575,6 +677,11 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "tidy$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "tidy",
},

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.UpdateOperation: ts.handleTidy,
},
Expand All @@ -586,6 +693,12 @@ func (ts *TokenStore) paths() []*framework.Path {

rolesPath := &framework.Path{
Pattern: "roles/" + framework.GenericNameRegex("role_name"),

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationSuffix: "role",
},

Fields: map[string]*framework.FieldSchema{
"role_name": {
Type: framework.TypeString,
Expand Down