Skip to content
Merged
Changes from all commits
Commits
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
30 changes: 30 additions & 0 deletions pkg/bao/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ const (
PKIProfile string = "pki"
TransitProfile string = "transit"
UserpassProfile string = "userpass"
SecretProfile string = "secret"
)

func ListProfiles() []string {
return []string{
PKIProfile,
TransitProfile,
UserpassProfile,
SecretProfile,
}
}

Expand All @@ -30,6 +32,8 @@ func ProfileDescription(name string) string {
return "enable transit for auto-unseal of another cluster"
case UserpassProfile:
return "enable userpass authentication and sample policy"
case SecretProfile:
return "enable a KVv2 static secret engine"
}

return ""
Expand All @@ -43,6 +47,8 @@ func ProfileSetup(client *api.Client, profile string) ([]string, error) {
return ProfileTransitSealMountSetup(client)
case UserpassProfile:
return ProfileUserpassMountSetup(client)
case SecretProfile:
return ProfileSecretMountSetup(client)
default:
return nil, fmt.Errorf("unknown profile to apply: %v", profile)
}
Expand All @@ -56,6 +62,8 @@ func ProfileRemove(client *api.Client, profile string) ([]string, error) {
return ProfileTransitSealMountRemove(client)
case UserpassProfile:
return ProfileUserpassMountRemove(client)
case SecretProfile:
return ProfileSecretMountRemove(client)
default:
return nil, fmt.Errorf("unknown profile to apply: %v", profile)
}
Expand Down Expand Up @@ -392,6 +400,10 @@ path "transit/random" {
path "transit/random/*" {
capabilities = ["create", "update"]
}

path "secret/+/scratch/*" {
capabilities = ["create", "read", "update", "patch", "list", "scan"]
}
`

func ProfileUserpassMountSetup(client *api.Client) ([]string, error) {
Expand Down Expand Up @@ -438,3 +450,21 @@ func ProfileUserpassMountRemove(client *api.Client) ([]string, error) {

return nil, nil
}

func ProfileSecretMountSetup(client *api.Client) ([]string, error) {
if err := client.Sys().Mount("secret", &api.MountInput{
Type: "kv-v2",
}); err != nil {
return nil, fmt.Errorf("failed to mount kv2 instance: %w", err)
}

return nil, nil
}

func ProfileSecretMountRemove(client *api.Client) ([]string, error) {
if err := client.Sys().Unmount("secret"); err != nil {
return nil, fmt.Errorf("failed to remove secret mount: %w", err)
}

return nil, nil
}
Loading