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 Radius auth #19392

Merged
merged 41 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 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
ae6a9e5
openapi: Add display attributes for Radius auth
averche Feb 28, 2023
fa9b052
with username
averche Feb 28, 2023
f4fc6e9
changelog
averche Feb 28, 2023
1644e43
Merge branch 'main' into ui/openapi-naming-strategy
averche Feb 28, 2023
8c9f4e7
Merge branch 'ui/openapi-naming-strategy' into display-attributes-radius
averche Mar 1, 2023
30b336f
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
211a2a6
config->configure
averche Mar 13, 2023
99c477b
configuration
averche Mar 21, 2023
6ed82cd
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
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
513ba8c
Merge branch 'ui/openapi-naming-strategy' into display-attributes-radius
averche Apr 4, 2023
e6814dc
Merge branch 'main' into display-attributes-radius
averche Apr 4, 2023
2c057fb
Merge branch 'main' into display-attributes-radius
averche Apr 5, 2023
fec11d6
Merge branch 'main' into display-attributes-radius
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/radius/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/hashicorp/vault/sdk/logical"
)

const operationPrefixRadius = "radius"

func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {
b := Backend()
if err := b.Setup(ctx, conf); err != nil {
Expand Down
32 changes: 25 additions & 7 deletions builtin/credential/radius/path_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import (
func pathConfig(b *backend) *framework.Path {
p := &framework.Path{
Pattern: "config",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixRadius,
Action: "Configure",
},

Fields: map[string]*framework.FieldSchema{
"host": {
Type: framework.TypeString,
Expand Down Expand Up @@ -80,17 +86,29 @@ func pathConfig(b *backend) *framework.Path {

ExistenceCheck: b.configExistenceCheck,

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathConfigRead,
logical.CreateOperation: b.pathConfigCreateUpdate,
logical.UpdateOperation: b.pathConfigCreateUpdate,
Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathConfigRead,
DisplayAttrs: &framework.DisplayAttributes{
OperationSuffix: "configuration",
},
},
logical.CreateOperation: &framework.PathOperation{
Callback: b.pathConfigCreateUpdate,
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "configure",
},
},
logical.UpdateOperation: &framework.PathOperation{
Callback: b.pathConfigCreateUpdate,
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "configure",
},
},
},

HelpSynopsis: pathConfigHelpSyn,
HelpDescription: pathConfigHelpDesc,
DisplayAttrs: &framework.DisplayAttributes{
Action: "Configure",
},
}

tokenutil.AddTokenFields(p.Fields)
Expand Down
7 changes: 7 additions & 0 deletions builtin/credential/radius/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ import (
func pathLogin(b *backend) *framework.Path {
return &framework.Path{
Pattern: "login" + framework.OptionalParamRegex("urlusername"),

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixRadius,
OperationVerb: "log-in",
OperationSuffix: "|with-username",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this result in 2 separate operation IDs for w/ and without user name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap:

radius-login
radius-login-with-username

},

Fields: map[string]*framework.FieldSchema{
"urlusername": {
Type: framework.TypeString,
Expand Down
23 changes: 15 additions & 8 deletions builtin/credential/radius/path_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,33 @@ func pathUsersList(b *backend) *framework.Path {
return &framework.Path{
Pattern: "users/?$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixRadius,
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 {
return &framework.Path{
Pattern: `users/(?P<name>.+)`,

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixRadius,
OperationSuffix: "user",
Action: "Create",
ItemType: "User",
},

Fields: map[string]*framework.FieldSchema{
"name": {
Type: framework.TypeString,
Expand All @@ -56,10 +67,6 @@ func pathUsers(b *backend) *framework.Path {

HelpSynopsis: pathUserHelpSyn,
HelpDescription: pathUserHelpDesc,
DisplayAttrs: &framework.DisplayAttributes{
Action: "Create",
ItemType: "User",
},
}
}

Expand Down