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 cert auth #19383

Merged
merged 47 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 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
7b3c8b2
openapi: Add display attributes for certs auth
averche Feb 27, 2023
7003717
hyphenate instead of TitleCase
averche Feb 27, 2023
4713d81
fmt
averche Feb 27, 2023
906a897
Merge branch 'ui/openapi-naming-strategy' into display-attributes-cert
averche Feb 27, 2023
0056734
hyphenate instead of TitleCase
averche Feb 27, 2023
8f61f73
changelog
averche Feb 27, 2023
1b5afe3
User OperationVerb since Action conflicts
averche Feb 27, 2023
54ad97a
reorder vars
averche Feb 27, 2023
4d11b71
Merge branch 'ui/openapi-naming-strategy' into display-attributes-cert
averche Feb 27, 2023
bbeb943
OperationVerb
averche Feb 27, 2023
1644e43
Merge branch 'main' into ui/openapi-naming-strategy
averche Feb 28, 2023
c552662
Merge branch 'ui/openapi-naming-strategy' into display-attributes-cert
averche Mar 1, 2023
0baf67c
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
44f5d9e
Merge branch 'ui/openapi-naming-strategy' into display-attributes-cert
averche Mar 13, 2023
57674b0
config -> configure
averche Mar 13, 2023
99aef41
configuration
averche Mar 20, 2023
404d98a
cert prefix
averche Mar 20, 2023
4c417db
log-in
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
8bad482
Merge branch 'ui/openapi-naming-strategy' into display-attributes-cert
averche Mar 28, 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
e48eb9e
Merge branch 'ui/openapi-naming-strategy' into display-attributes-cert
averche Apr 4, 2023
db09b56
Merge branch 'main' into display-attributes-cert
averche Apr 4, 2023
d4fa4f1
Merge branch 'main' into display-attributes-cert
averche Apr 5, 2023
4ec6a23
Merge branch 'main' into display-attributes-cert
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
2 changes: 2 additions & 0 deletions builtin/credential/cert/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"github.com/hashicorp/vault/sdk/logical"
)

const operationPrefixCert = "cert"

func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := Backend()
if err := b.Setup(ctx, conf); err != nil {
Expand Down
23 changes: 15 additions & 8 deletions builtin/credential/cert/path_certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,33 @@ func pathListCerts(b *backend) *framework.Path {
return &framework.Path{
Pattern: "certs/?",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixCert,
OperationSuffix: "certificates",
Navigation: true,
ItemType: "Certificate",
},

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ListOperation: b.pathCertList,
},

HelpSynopsis: pathCertHelpSyn,
HelpDescription: pathCertHelpDesc,
DisplayAttrs: &framework.DisplayAttributes{
Navigation: true,
ItemType: "Certificate",
},
}
}

func pathCerts(b *backend) *framework.Path {
p := &framework.Path{
Pattern: "certs/" + framework.GenericNameRegex("name"),

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixCert,
OperationSuffix: "certificate",
Action: "Create",
ItemType: "Certificate",
},

Fields: map[string]*framework.FieldSchema{
"name": {
Type: framework.TypeString,
Expand Down Expand Up @@ -202,10 +213,6 @@ certificate.`,

HelpSynopsis: pathCertHelpSyn,
HelpDescription: pathCertHelpDesc,
DisplayAttrs: &framework.DisplayAttributes{
Action: "Create",
ItemType: "Certificate",
},
}

tokenutil.AddTokenFields(p.Fields)
Expand Down
21 changes: 18 additions & 3 deletions builtin/credential/cert/path_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ const maxCacheSize = 100000
func pathConfig(b *backend) *framework.Path {
return &framework.Path{
Pattern: "config",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixCert,
},

Fields: map[string]*framework.FieldSchema{
"disable_binding": {
Type: framework.TypeBool,
Expand All @@ -34,9 +39,19 @@ func pathConfig(b *backend) *framework.Path {
},
},

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.UpdateOperation: b.pathConfigWrite,
logical.ReadOperation: b.pathConfigRead,
Operations: map[logical.Operation]framework.OperationHandler{
logical.UpdateOperation: &framework.PathOperation{
Callback: b.pathConfigWrite,
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "configure",
},
},
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathConfigRead,
DisplayAttrs: &framework.DisplayAttributes{
OperationSuffix: "configuration",
},
},
},
}
}
Expand Down
10 changes: 10 additions & 0 deletions builtin/credential/cert/path_crls.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import (
func pathListCRLs(b *backend) *framework.Path {
return &framework.Path{
Pattern: "crls/?$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixCert,
OperationSuffix: "crls",
},
Operations: map[logical.Operation]framework.OperationHandler{
logical.ListOperation: &framework.PathOperation{
Callback: b.pathCRLsList,
Expand All @@ -44,6 +48,12 @@ func (b *backend) pathCRLsList(ctx context.Context, req *logical.Request, d *fra
func pathCRLs(b *backend) *framework.Path {
return &framework.Path{
Pattern: "crls/" + framework.GenericNameRegex("name"),

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixCert,
OperationSuffix: "crl",
},

Fields: map[string]*framework.FieldSchema{
"name": {
Type: framework.TypeString,
Expand Down
4 changes: 4 additions & 0 deletions builtin/credential/cert/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type ParsedCert struct {
func pathLogin(b *backend) *framework.Path {
return &framework.Path{
Pattern: "login",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixCert,
OperationVerb: "log-in",
},
Fields: map[string]*framework.FieldSchema{
"name": {
Type: framework.TypeString,
Expand Down