Skip to content

Commit

Permalink
openapi: Add display attributes for Radius auth (#19392)
Browse files Browse the repository at this point in the history
  • Loading branch information
averche authored Apr 7, 2023
1 parent ab23a03 commit 151ddc6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 15 deletions.
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",
},

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

0 comments on commit 151ddc6

Please sign in to comment.