openapi: Add display attributes for userpass (#19411)

This commit is contained in:
Anton Averchenkov 2023-04-13 11:30:54 -04:00 committed by GitHub
parent 9a654ac3f1
commit c8803cb571
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 8 deletions

View File

@ -10,6 +10,8 @@ import (
"github.com/hashicorp/vault/sdk/logical"
)
const operationPrefixUserpass = "userpass"
func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := Backend()
if err := b.Setup(ctx, conf); err != nil {

View File

@ -19,6 +19,12 @@ import (
func pathLogin(b *backend) *framework.Path {
return &framework.Path{
Pattern: "login/" + framework.GenericNameRegex("username"),
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixUserpass,
OperationVerb: "log-in",
},
Fields: map[string]*framework.FieldSchema{
"username": {
Type: framework.TypeString,

View File

@ -16,6 +16,13 @@ import (
func pathUserPassword(b *backend) *framework.Path {
return &framework.Path{
Pattern: "users/" + framework.GenericNameRegex("username") + "/password$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixUserpass,
OperationVerb: "reset",
OperationSuffix: "password",
},
Fields: map[string]*framework.FieldSchema{
"username": {
Type: framework.TypeString,

View File

@ -16,6 +16,13 @@ import (
func pathUserPolicies(b *backend) *framework.Path {
return &framework.Path{
Pattern: "users/" + framework.GenericNameRegex("username") + "/policies$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixUserpass,
OperationVerb: "update",
OperationSuffix: "policies",
},
Fields: map[string]*framework.FieldSchema{
"username": {
Type: framework.TypeString,

View File

@ -19,22 +19,33 @@ func pathUsersList(b *backend) *framework.Path {
return &framework.Path{
Pattern: "users/?",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixUserpass,
OperationSuffix: "users",
Navigation: true,
ItemType: "User",
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ListOperation: b.pathUserList,
},
HelpSynopsis: pathUserHelpSyn,
HelpDescription: pathUserHelpDesc,
DisplayAttrs: &framework.DisplayAttributes{
Navigation: true,
ItemType: "User",
},
}
}
func pathUsers(b *backend) *framework.Path {
p := &framework.Path{
Pattern: "users/" + framework.GenericNameRegex("username"),
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixUserpass,
OperationSuffix: "user",
Action: "Create",
ItemType: "User",
},
Fields: map[string]*framework.FieldSchema{
"username": {
Type: framework.TypeString,
@ -85,10 +96,6 @@ func pathUsers(b *backend) *framework.Path {
HelpSynopsis: pathUserHelpSyn,
HelpDescription: pathUserHelpDesc,
DisplayAttrs: &framework.DisplayAttributes{
Action: "Create",
ItemType: "User",
},
}
tokenutil.AddTokenFields(p.Fields)