openapi: Add display attributes for token/ (#19399)

This commit is contained in:
Anton Averchenkov 2023-04-06 11:11:49 -04:00 committed by GitHub
parent 543efc83e4
commit 56698d6d15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 119 additions and 6 deletions

View File

@ -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,
},
@ -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,
},
@ -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,
@ -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",
},
Fields: map[string]*framework.FieldSchema{
"role_name": {
Type: framework.TypeString,
@ -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,
@ -385,6 +414,11 @@ func (ts *TokenStore) paths() []*framework.Path {
{
Pattern: "lookup",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixToken,
OperationVerb: "look-up",
},
Fields: map[string]*framework.FieldSchema{
"token": {
Type: framework.TypeString,
@ -392,9 +426,16 @@ func (ts *TokenStore) paths() []*framework.Path {
},
},
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),
@ -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,
@ -422,6 +469,11 @@ 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,
@ -429,9 +481,19 @@ func (ts *TokenStore) paths() []*framework.Path {
},
},
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",
},
},
},
HelpSynopsis: strings.TrimSpace(tokenLookupHelp),
@ -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,
@ -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,
},
@ -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,
@ -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,
@ -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,
@ -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,
@ -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,
@ -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,
},
@ -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,