openapi: Add display attributes for Okta auth (#19391)

This commit is contained in:
Anton Averchenkov 2023-04-13 11:29:59 -04:00 committed by GitHub
parent 21b6eee698
commit 9a654ac3f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 68 additions and 25 deletions

View File

@ -18,8 +18,9 @@ import (
)
const (
mfaPushMethod = "push"
mfaTOTPMethod = "token:software:totp"
operationPrefixOkta = "okta"
mfaPushMethod = "push"
mfaTOTPMethod = "token:software:totp"
)
func Factory(ctx context.Context, conf *logical.BackendConfig) (logical.Backend, error) {

View File

@ -27,6 +27,12 @@ const (
func pathConfig(b *backend) *framework.Path {
p := &framework.Path{
Pattern: `config`,
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixOkta,
Action: "Configure",
},
Fields: map[string]*framework.FieldSchema{
"organization": {
Type: framework.TypeString,
@ -83,18 +89,30 @@ func pathConfig(b *backend) *framework.Path {
},
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathConfigRead,
logical.CreateOperation: b.pathConfigWrite,
logical.UpdateOperation: b.pathConfigWrite,
Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathConfigRead,
DisplayAttrs: &framework.DisplayAttributes{
OperationSuffix: "configuration",
},
},
logical.CreateOperation: &framework.PathOperation{
Callback: b.pathConfigWrite,
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "configure",
},
},
logical.UpdateOperation: &framework.PathOperation{
Callback: b.pathConfigWrite,
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "configure",
},
},
},
ExistenceCheck: b.pathConfigExistenceCheck,
HelpSynopsis: pathConfigHelp,
DisplayAttrs: &framework.DisplayAttributes{
Action: "Configure",
},
}
tokenutil.AddTokenFields(p.Fields)

View File

@ -16,22 +16,33 @@ func pathGroupsList(b *backend) *framework.Path {
return &framework.Path{
Pattern: "groups/?$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixOkta,
OperationSuffix: "groups",
Navigation: true,
ItemType: "Group",
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ListOperation: b.pathGroupList,
},
HelpSynopsis: pathGroupHelpSyn,
HelpDescription: pathGroupHelpDesc,
DisplayAttrs: &framework.DisplayAttributes{
Navigation: true,
ItemType: "Group",
},
}
}
func pathGroups(b *backend) *framework.Path {
return &framework.Path{
Pattern: `groups/(?P<name>.+)`,
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixOkta,
OperationSuffix: "group",
Action: "Create",
ItemType: "Group",
},
Fields: map[string]*framework.FieldSchema{
"name": {
Type: framework.TypeString,
@ -52,10 +63,6 @@ func pathGroups(b *backend) *framework.Path {
HelpSynopsis: pathGroupHelpSyn,
HelpDescription: pathGroupHelpDesc,
DisplayAttrs: &framework.DisplayAttributes{
Action: "Create",
ItemType: "Group",
},
}
}

View File

@ -23,6 +23,12 @@ const (
func pathLogin(b *backend) *framework.Path {
return &framework.Path{
Pattern: `login/(?P<username>.+)`,
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixOkta,
OperationVerb: "log-in",
},
Fields: map[string]*framework.FieldSchema{
"username": {
Type: framework.TypeString,
@ -192,6 +198,10 @@ func (b *backend) pathLoginRenew(ctx context.Context, req *logical.Request, d *f
func pathVerify(b *backend) *framework.Path {
return &framework.Path{
Pattern: `verify/(?P<nonce>.+)`,
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixOkta,
OperationVerb: "verify",
},
Fields: map[string]*framework.FieldSchema{
"nonce": {
Type: framework.TypeString,

View File

@ -14,22 +14,33 @@ func pathUsersList(b *backend) *framework.Path {
return &framework.Path{
Pattern: "users/?$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixOkta,
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: operationPrefixOkta,
OperationSuffix: "user",
Action: "Create",
ItemType: "User",
},
Fields: map[string]*framework.FieldSchema{
"name": {
Type: framework.TypeString,
@ -55,10 +66,6 @@ func pathUsers(b *backend) *framework.Path {
HelpSynopsis: pathUserHelpSyn,
HelpDescription: pathUserHelpDesc,
DisplayAttrs: &framework.DisplayAttributes{
Action: "Create",
ItemType: "User",
},
}
}