From 5bf28695d27e65c12bf1e04ed675f7741b8710b6 Mon Sep 17 00:00:00 2001 From: "Gaige B. Paulsen" Date: Fri, 20 Feb 2026 05:07:04 -0500 Subject: [PATCH 1/3] feat: add support for openbao fix: BAO prefix --- plugins/openbao/auth_token.go | 57 ++++++++++++++++++++++++++++++ plugins/openbao/auth_token_test.go | 49 +++++++++++++++++++++++++ plugins/openbao/bao.go | 25 +++++++++++++ plugins/openbao/plugin.go | 22 ++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 plugins/openbao/auth_token.go create mode 100644 plugins/openbao/auth_token_test.go create mode 100644 plugins/openbao/bao.go create mode 100644 plugins/openbao/plugin.go diff --git a/plugins/openbao/auth_token.go b/plugins/openbao/auth_token.go new file mode 100644 index 000000000..09b726d96 --- /dev/null +++ b/plugins/openbao/auth_token.go @@ -0,0 +1,57 @@ +package openbao + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/importer" + "github.com/1Password/shell-plugins/sdk/provision" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func AuthToken() schema.CredentialType { + return schema.CredentialType{ + Name: credname.AuthToken, + DocsURL: sdk.URL("https://openbao.org/docs/concepts/tokens/"), + ManagementURL: nil, + Fields: []schema.CredentialField{ + { + Name: fieldname.Token, + MarkdownDescription: "Token used to authenticate to OpenBao.", + Secret: true, + Composition: &schema.ValueComposition{ + Charset: schema.Charset{ + Uppercase: true, + Lowercase: true, + Digits: true, + }, + }, + }, + { + Name: fieldname.Address, + MarkdownDescription: "Default address of the Vault server to use for this auth token.", + Optional: true, + }, + { + Name: fieldname.Namespace, + MarkdownDescription: "Default namespace to use for this auth token.", + Optional: true, + }, + }, + DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), + Importer: importer.TryAll( + importer.TryEnvVarPair(defaultEnvVarMapping), + TryOpenBaoConfigFile(), + )} +} + +var defaultEnvVarMapping = map[string]sdk.FieldName{ + "BAO_TOKEN": fieldname.Token, + "BAO_ADDR": fieldname.Address, + "BAO_NAMESPACE": fieldname.Namespace, +} + +func TryOpenBaoConfigFile() sdk.Importer { + return importer.NoOp() +} + diff --git a/plugins/openbao/auth_token_test.go b/plugins/openbao/auth_token_test.go new file mode 100644 index 000000000..cd88385d1 --- /dev/null +++ b/plugins/openbao/auth_token_test.go @@ -0,0 +1,49 @@ +package openbao + +import ( + "testing" + + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/plugintest" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func TestAuthTokenProvisioner(t *testing.T) { + plugintest.TestProvisioner(t, Token().DefaultProvisioner, map[string]plugintest.ProvisionCase{ + "default": { + ItemFields: map[sdk.FieldName]string { + fieldname.Token: "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", + fieldname.Address: "https://bao.acme.com", + fieldname.Namespace: "default", + }, + ExpectedOutput: sdk.ProvisionOutput{ + Environment: map[string]string{ + "BAO_TOKEN": "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", + "BAO_ADDR": "https://bao.acme.com", + "BAO_NAMESPACE": "default", + }, + }, + }, + }) +} + +func TestAuthTokenImporter(t *testing.T) { + plugintest.TestImporter(t, Token().Importer, map[string]plugintest.ImportCase{ + "environment": { + Environment: map[string]string { + "BAO_TOKEN": "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", + "BAO_ADDR": "https://bao.acme.com", + "BAO_NAMESPACE": "default", + }, + ExpectedCandidates: []sdk.ImportCandidate{ + { + Fields: map[sdk.FieldName]string{ + fieldname.Token: "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", + fieldname.Address: "https://bao.acme.com", + fieldname.Namespace: "default", + }, + }, + }, + }, + }) +} diff --git a/plugins/openbao/bao.go b/plugins/openbao/bao.go new file mode 100644 index 000000000..7a84d98c0 --- /dev/null +++ b/plugins/openbao/bao.go @@ -0,0 +1,25 @@ +package openbao + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/needsauth" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" +) + +func OpenBaoCLI() schema.Executable { + return schema.Executable{ + Name: "OpenBao CLI", // TODO: Check if this is correct + Runs: []string{"bao"}, + DocsURL: sdk.URL("https://openbao.com/docs/cli"), // TODO: Replace with actual URL + NeedsAuth: needsauth.IfAll( + needsauth.NotForHelpOrVersion(), + needsauth.NotWithoutArgs(), + ), + Uses: []schema.CredentialUsage{ + { + Name: credname.AuthToken, + }, + }, + } +} diff --git a/plugins/openbao/plugin.go b/plugins/openbao/plugin.go new file mode 100644 index 000000000..dcf753a3b --- /dev/null +++ b/plugins/openbao/plugin.go @@ -0,0 +1,22 @@ +package openbao + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/schema" +) + +func New() schema.Plugin { + return schema.Plugin{ + Name: "openbao", + Platform: schema.PlatformInfo{ + Name: "OpenBao", + Homepage: sdk.URL("https://openbao.org"), + }, + Credentials: []schema.CredentialType{ + AuthToken(), + }, + Executables: []schema.Executable{ + OpenBaoCLI(), + }, + } +} From 24a0a2ba4426a438576064ada21b61019d25a856 Mon Sep 17 00:00:00 2001 From: Gaige B Paulsen Date: Mon, 12 Oct 2026 06:45:40 -0400 Subject: [PATCH 2/3] Update tests to use AuthToken instead of Token --- plugins/openbao/auth_token_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/openbao/auth_token_test.go b/plugins/openbao/auth_token_test.go index cd88385d1..d913dd0e2 100644 --- a/plugins/openbao/auth_token_test.go +++ b/plugins/openbao/auth_token_test.go @@ -9,7 +9,7 @@ import ( ) func TestAuthTokenProvisioner(t *testing.T) { - plugintest.TestProvisioner(t, Token().DefaultProvisioner, map[string]plugintest.ProvisionCase{ + plugintest.TestProvisioner(t, AuthToken().DefaultProvisioner, map[string]plugintest.ProvisionCase{ "default": { ItemFields: map[sdk.FieldName]string { fieldname.Token: "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", @@ -28,7 +28,7 @@ func TestAuthTokenProvisioner(t *testing.T) { } func TestAuthTokenImporter(t *testing.T) { - plugintest.TestImporter(t, Token().Importer, map[string]plugintest.ImportCase{ + plugintest.TestImporter(t, AuthToken().Importer, map[string]plugintest.ImportCase{ "environment": { Environment: map[string]string { "BAO_TOKEN": "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", From 19fab57e7e2bccdead25f1b855a291585bd1fa07 Mon Sep 17 00:00:00 2001 From: "Gaige B. Paulsen" Date: Tue, 13 Oct 2026 05:53:51 -0400 Subject: [PATCH 3/3] chore: fix format --- plugins/openbao/auth_token.go | 1 - plugins/openbao/auth_token_test.go | 16 ++++++++-------- plugins/openbao/bao.go | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/openbao/auth_token.go b/plugins/openbao/auth_token.go index 09b726d96..4721b53ef 100644 --- a/plugins/openbao/auth_token.go +++ b/plugins/openbao/auth_token.go @@ -54,4 +54,3 @@ var defaultEnvVarMapping = map[string]sdk.FieldName{ func TryOpenBaoConfigFile() sdk.Importer { return importer.NoOp() } - diff --git a/plugins/openbao/auth_token_test.go b/plugins/openbao/auth_token_test.go index d913dd0e2..c2d249312 100644 --- a/plugins/openbao/auth_token_test.go +++ b/plugins/openbao/auth_token_test.go @@ -2,18 +2,18 @@ package openbao import ( "testing" - + "github.com/1Password/shell-plugins/sdk" "github.com/1Password/shell-plugins/sdk/plugintest" "github.com/1Password/shell-plugins/sdk/schema/fieldname" ) - + func TestAuthTokenProvisioner(t *testing.T) { plugintest.TestProvisioner(t, AuthToken().DefaultProvisioner, map[string]plugintest.ProvisionCase{ "default": { - ItemFields: map[sdk.FieldName]string { - fieldname.Token: "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", - fieldname.Address: "https://bao.acme.com", + ItemFields: map[sdk.FieldName]string{ + fieldname.Token: "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", + fieldname.Address: "https://bao.acme.com", fieldname.Namespace: "default", }, ExpectedOutput: sdk.ProvisionOutput{ @@ -30,7 +30,7 @@ func TestAuthTokenProvisioner(t *testing.T) { func TestAuthTokenImporter(t *testing.T) { plugintest.TestImporter(t, AuthToken().Importer, map[string]plugintest.ImportCase{ "environment": { - Environment: map[string]string { + Environment: map[string]string{ "BAO_TOKEN": "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", "BAO_ADDR": "https://bao.acme.com", "BAO_NAMESPACE": "default", @@ -38,8 +38,8 @@ func TestAuthTokenImporter(t *testing.T) { ExpectedCandidates: []sdk.ImportCandidate{ { Fields: map[sdk.FieldName]string{ - fieldname.Token: "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", - fieldname.Address: "https://bao.acme.com", + fieldname.Token: "s.UrpjvNwnaPjTFFj2RAyEXAMPLE", + fieldname.Address: "https://bao.acme.com", fieldname.Namespace: "default", }, }, diff --git a/plugins/openbao/bao.go b/plugins/openbao/bao.go index 7a84d98c0..4d0b8e1f8 100644 --- a/plugins/openbao/bao.go +++ b/plugins/openbao/bao.go @@ -9,9 +9,9 @@ import ( func OpenBaoCLI() schema.Executable { return schema.Executable{ - Name: "OpenBao CLI", // TODO: Check if this is correct - Runs: []string{"bao"}, - DocsURL: sdk.URL("https://openbao.com/docs/cli"), // TODO: Replace with actual URL + Name: "OpenBao CLI", // TODO: Check if this is correct + Runs: []string{"bao"}, + DocsURL: sdk.URL("https://openbao.com/docs/cli"), // TODO: Replace with actual URL NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), needsauth.NotWithoutArgs(),