2023-03-15 19:00:52 +03:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2024-01-02 21:36:20 +03:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-15 19:00:52 +03:00
|
|
|
|
2017-10-11 20:21:20 +03:00
|
|
|
package vault
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2019-04-13 00:54:35 +03:00
|
|
|
"github.com/hashicorp/vault/sdk/framework"
|
2019-04-13 10:44:06 +03:00
|
|
|
"github.com/hashicorp/vault/sdk/logical"
|
2017-10-11 20:21:20 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func upgradePaths(i *IdentityStore) []*framework.Path {
|
|
|
|
return []*framework.Path{
|
|
|
|
{
|
|
|
|
Pattern: "persona$",
|
2023-04-12 22:46:01 +03:00
|
|
|
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationPrefix: "persona",
|
|
|
|
OperationVerb: "create",
|
|
|
|
},
|
|
|
|
|
2017-10-11 20:21:20 +03:00
|
|
|
Fields: map[string]*framework.FieldSchema{
|
|
|
|
"id": {
|
|
|
|
Type: framework.TypeString,
|
2018-07-25 05:01:58 +03:00
|
|
|
Description: "ID of the persona",
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
"entity_id": {
|
|
|
|
Type: framework.TypeString,
|
2018-07-25 05:01:58 +03:00
|
|
|
Description: "Entity ID to which this persona belongs to",
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
"mount_accessor": {
|
|
|
|
Type: framework.TypeString,
|
2018-07-25 05:01:58 +03:00
|
|
|
Description: "Mount accessor to which this persona belongs to",
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
"name": {
|
|
|
|
Type: framework.TypeString,
|
2018-07-25 05:01:58 +03:00
|
|
|
Description: "Name of the persona",
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
"metadata": {
|
2017-11-14 04:59:42 +03:00
|
|
|
Type: framework.TypeKVPairs,
|
2018-07-25 05:01:58 +03:00
|
|
|
Description: `Metadata to be associated with the persona.
|
2017-11-14 04:59:42 +03:00
|
|
|
In CLI, this parameter can be repeated multiple times, and it all gets merged together.
|
|
|
|
For example:
|
|
|
|
vault <command> <path> metadata=key1=value1 metadata=key2=value2
|
|
|
|
`,
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
2018-07-25 05:01:58 +03:00
|
|
|
logical.UpdateOperation: i.handleEntityUpdateCommon(),
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
HelpSynopsis: strings.TrimSpace(aliasHelp["alias"][0]),
|
|
|
|
HelpDescription: strings.TrimSpace(aliasHelp["alias"][1]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Pattern: "persona/id/" + framework.GenericNameRegex("id"),
|
2023-04-12 22:46:01 +03:00
|
|
|
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationPrefix: "persona",
|
|
|
|
OperationSuffix: "by-id",
|
|
|
|
},
|
|
|
|
|
2017-10-11 20:21:20 +03:00
|
|
|
Fields: map[string]*framework.FieldSchema{
|
|
|
|
"id": {
|
|
|
|
Type: framework.TypeString,
|
2018-07-25 05:01:58 +03:00
|
|
|
Description: "ID of the persona",
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
"entity_id": {
|
|
|
|
Type: framework.TypeString,
|
2018-07-25 05:01:58 +03:00
|
|
|
Description: "Entity ID to which this persona should be tied to",
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
"mount_accessor": {
|
|
|
|
Type: framework.TypeString,
|
2018-07-25 05:01:58 +03:00
|
|
|
Description: "Mount accessor to which this persona belongs to",
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
"name": {
|
|
|
|
Type: framework.TypeString,
|
2018-07-25 05:01:58 +03:00
|
|
|
Description: "Name of the persona",
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
"metadata": {
|
2017-11-14 04:59:42 +03:00
|
|
|
Type: framework.TypeKVPairs,
|
2018-07-25 05:01:58 +03:00
|
|
|
Description: `Metadata to be associated with the persona.
|
2017-11-14 04:59:42 +03:00
|
|
|
In CLI, this parameter can be repeated multiple times, and it all gets merged together.
|
|
|
|
For example:
|
|
|
|
vault <command> <path> metadata=key1=value1 metadata=key2=value2
|
|
|
|
`,
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
},
|
2023-04-12 22:46:01 +03:00
|
|
|
|
|
|
|
Operations: map[logical.Operation]framework.OperationHandler{
|
|
|
|
logical.UpdateOperation: &framework.PathOperation{
|
|
|
|
Callback: i.handleEntityUpdateCommon(),
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationVerb: "update",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
logical.ReadOperation: &framework.PathOperation{
|
|
|
|
Callback: i.pathAliasIDRead(),
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationVerb: "read",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
logical.DeleteOperation: &framework.PathOperation{
|
|
|
|
Callback: i.pathAliasIDDelete(),
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationVerb: "delete",
|
|
|
|
},
|
|
|
|
},
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
HelpSynopsis: strings.TrimSpace(aliasHelp["alias-id"][0]),
|
|
|
|
HelpDescription: strings.TrimSpace(aliasHelp["alias-id"][1]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Pattern: "persona/id/?$",
|
2023-04-12 22:46:01 +03:00
|
|
|
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationPrefix: "persona",
|
|
|
|
OperationSuffix: "by-id",
|
|
|
|
},
|
|
|
|
|
2017-10-11 20:21:20 +03:00
|
|
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
2018-01-08 21:31:38 +03:00
|
|
|
logical.ListOperation: i.pathAliasIDList(),
|
2017-10-11 20:21:20 +03:00
|
|
|
},
|
|
|
|
|
2017-11-14 04:59:42 +03:00
|
|
|
HelpSynopsis: strings.TrimSpace(aliasHelp["alias-id-list"][0]),
|
|
|
|
HelpDescription: strings.TrimSpace(aliasHelp["alias-id-list"][1]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Pattern: "alias$",
|
2023-04-12 22:46:01 +03:00
|
|
|
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationPrefix: "alias",
|
|
|
|
OperationVerb: "create",
|
|
|
|
},
|
|
|
|
|
2017-11-14 04:59:42 +03:00
|
|
|
Fields: map[string]*framework.FieldSchema{
|
|
|
|
"id": {
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "ID of the alias",
|
|
|
|
},
|
|
|
|
"entity_id": {
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Entity ID to which this alias belongs to. This field is deprecated in favor of 'canonical_id'.",
|
|
|
|
},
|
|
|
|
"canonical_id": {
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Entity ID to which this alias belongs to",
|
|
|
|
},
|
|
|
|
"mount_accessor": {
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Mount accessor to which this alias belongs to",
|
|
|
|
},
|
|
|
|
"name": {
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Name of the alias",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
2019-06-14 19:53:00 +03:00
|
|
|
logical.UpdateOperation: i.handleAliasCreateUpdate(),
|
2017-11-14 04:59:42 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
HelpSynopsis: strings.TrimSpace(aliasHelp["alias"][0]),
|
|
|
|
HelpDescription: strings.TrimSpace(aliasHelp["alias"][1]),
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
Pattern: "alias/id/" + framework.GenericNameRegex("id"),
|
2023-04-12 22:46:01 +03:00
|
|
|
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationPrefix: "alias",
|
|
|
|
OperationSuffix: "by-id",
|
|
|
|
},
|
|
|
|
|
2017-11-14 04:59:42 +03:00
|
|
|
Fields: map[string]*framework.FieldSchema{
|
|
|
|
"id": {
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "ID of the alias",
|
|
|
|
},
|
|
|
|
"entity_id": {
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Entity ID to which this alias should be tied to. This field is deprecated in favor of 'canonical_id'.",
|
|
|
|
},
|
|
|
|
"canonical_id": {
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Entity ID to which this alias should be tied to",
|
|
|
|
},
|
|
|
|
"mount_accessor": {
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Mount accessor to which this alias belongs to",
|
|
|
|
},
|
|
|
|
"name": {
|
|
|
|
Type: framework.TypeString,
|
|
|
|
Description: "Name of the alias",
|
|
|
|
},
|
|
|
|
},
|
2023-04-12 22:46:01 +03:00
|
|
|
|
|
|
|
Operations: map[logical.Operation]framework.OperationHandler{
|
|
|
|
logical.UpdateOperation: &framework.PathOperation{
|
|
|
|
Callback: i.handleAliasCreateUpdate(),
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationVerb: "update",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
logical.ReadOperation: &framework.PathOperation{
|
|
|
|
Callback: i.pathAliasIDRead(),
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationVerb: "read",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
logical.DeleteOperation: &framework.PathOperation{
|
|
|
|
Callback: i.pathAliasIDDelete(),
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationVerb: "delete",
|
|
|
|
},
|
|
|
|
},
|
2017-11-14 04:59:42 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
HelpSynopsis: strings.TrimSpace(aliasHelp["alias-id"][0]),
|
|
|
|
HelpDescription: strings.TrimSpace(aliasHelp["alias-id"][1]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Pattern: "alias/id/?$",
|
2023-04-12 22:46:01 +03:00
|
|
|
|
|
|
|
DisplayAttrs: &framework.DisplayAttributes{
|
|
|
|
OperationPrefix: "alias",
|
|
|
|
OperationSuffix: "by-id",
|
|
|
|
},
|
|
|
|
|
2017-11-14 04:59:42 +03:00
|
|
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
2018-01-08 21:31:38 +03:00
|
|
|
logical.ListOperation: i.pathAliasIDList(),
|
2017-11-14 04:59:42 +03:00
|
|
|
},
|
|
|
|
|
2017-10-11 20:21:20 +03:00
|
|
|
HelpSynopsis: strings.TrimSpace(aliasHelp["alias-id-list"][0]),
|
|
|
|
HelpDescription: strings.TrimSpace(aliasHelp["alias-id-list"][1]),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|