openapi: Add display attributes for TOTP plugin (#19544)
This commit is contained in:
parent
f0fc48c788
commit
592d3464f6
|
@ -13,6 +13,8 @@ import (
|
|||
cache "github.com/patrickmn/go-cache"
|
||||
)
|
||||
|
||||
const operationPrefixTOTP = "totp"
|
||||
|
||||
func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
|
||||
b := Backend()
|
||||
if err := b.Setup(ctx, conf); err != nil {
|
||||
|
|
|
@ -17,6 +17,12 @@ import (
|
|||
func pathCode(b *backend) *framework.Path {
|
||||
return &framework.Path{
|
||||
Pattern: "code/" + framework.GenericNameWithAtRegex("name"),
|
||||
|
||||
DisplayAttrs: &framework.DisplayAttributes{
|
||||
OperationPrefix: operationPrefixTOTP,
|
||||
OperationSuffix: "code",
|
||||
},
|
||||
|
||||
Fields: map[string]*framework.FieldSchema{
|
||||
"name": {
|
||||
Type: framework.TypeString,
|
||||
|
@ -28,9 +34,19 @@ func pathCode(b *backend) *framework.Path {
|
|||
},
|
||||
},
|
||||
|
||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||
logical.ReadOperation: b.pathReadCode,
|
||||
logical.UpdateOperation: b.pathValidateCode,
|
||||
Operations: map[logical.Operation]framework.OperationHandler{
|
||||
logical.ReadOperation: &framework.PathOperation{
|
||||
Callback: b.pathReadCode,
|
||||
DisplayAttrs: &framework.DisplayAttributes{
|
||||
OperationVerb: "generate",
|
||||
},
|
||||
},
|
||||
logical.UpdateOperation: &framework.PathOperation{
|
||||
Callback: b.pathValidateCode,
|
||||
DisplayAttrs: &framework.DisplayAttributes{
|
||||
OperationVerb: "validate",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
HelpSynopsis: pathCodeHelpSyn,
|
||||
|
|
|
@ -24,6 +24,11 @@ func pathListKeys(b *backend) *framework.Path {
|
|||
return &framework.Path{
|
||||
Pattern: "keys/?$",
|
||||
|
||||
DisplayAttrs: &framework.DisplayAttributes{
|
||||
OperationPrefix: operationPrefixTOTP,
|
||||
OperationSuffix: "keys",
|
||||
},
|
||||
|
||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||
logical.ListOperation: b.pathKeyList,
|
||||
},
|
||||
|
@ -36,6 +41,12 @@ func pathListKeys(b *backend) *framework.Path {
|
|||
func pathKeys(b *backend) *framework.Path {
|
||||
return &framework.Path{
|
||||
Pattern: "keys/" + framework.GenericNameWithAtRegex("name"),
|
||||
|
||||
DisplayAttrs: &framework.DisplayAttributes{
|
||||
OperationPrefix: operationPrefixTOTP,
|
||||
OperationSuffix: "key",
|
||||
},
|
||||
|
||||
Fields: map[string]*framework.FieldSchema{
|
||||
"name": {
|
||||
Type: framework.TypeString,
|
||||
|
@ -111,10 +122,25 @@ func pathKeys(b *backend) *framework.Path {
|
|||
},
|
||||
},
|
||||
|
||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||
logical.ReadOperation: b.pathKeyRead,
|
||||
logical.UpdateOperation: b.pathKeyCreate,
|
||||
logical.DeleteOperation: b.pathKeyDelete,
|
||||
Operations: map[logical.Operation]framework.OperationHandler{
|
||||
logical.ReadOperation: &framework.PathOperation{
|
||||
Callback: b.pathKeyRead,
|
||||
DisplayAttrs: &framework.DisplayAttributes{
|
||||
OperationVerb: "read",
|
||||
},
|
||||
},
|
||||
logical.UpdateOperation: &framework.PathOperation{
|
||||
Callback: b.pathKeyCreate,
|
||||
DisplayAttrs: &framework.DisplayAttributes{
|
||||
OperationVerb: "create",
|
||||
},
|
||||
},
|
||||
logical.DeleteOperation: &framework.PathOperation{
|
||||
Callback: b.pathKeyDelete,
|
||||
DisplayAttrs: &framework.DisplayAttributes{
|
||||
OperationVerb: "delete",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
HelpSynopsis: pathKeyHelpSyn,
|
||||
|
|
Loading…
Reference in New Issue