From 1a72fce851df5a2e0b84772b0e8265dc900c2728 Mon Sep 17 00:00:00 2001 From: miwr Date: Mon, 2 Dec 2024 10:51:23 +0100 Subject: [PATCH] demo --- .history/agent-config_20241107145131.hcl | 64 ++++++++++++++++++++++ .history/agent-config_20241107145904.hcl | 64 ++++++++++++++++++++++ .history/agent-config_20241107145928.hcl | 64 ++++++++++++++++++++++ .history/main_20241107142952.go | 0 .history/main_20241107143236.go | 1 + .history/main_20241107143239.go | 1 + .history/main_20241107143242.go | 3 ++ .history/main_20241107143247.go | 3 ++ .history/main_20241107143249.go | 3 ++ .history/main_20241107143252.go | 5 ++ .history/main_20241107143257.go | 7 +++ .history/main_20241107143258.go | 7 +++ .history/main_20241107143300.go | 7 +++ .history/main_20241107143506.go | 8 +++ .history/main_20241107143528.go | 17 ++++++ .history/main_20241107143534.go | 21 ++++++++ .history/main_20241107143540.go | 21 ++++++++ .history/main_20241107143541.go | 21 ++++++++ .history/main_20241107143543.go | 21 ++++++++ .history/main_20241107143546.go | 21 ++++++++ .history/main_20241107143550.go | 20 +++++++ .history/main_20241107143556.go | 21 ++++++++ .history/main_20241107143558.go | 21 ++++++++ .history/main_20241107143600.go | 21 ++++++++ .history/main_20241107143606.go | 21 ++++++++ .history/main_20241107143644.go | 25 +++++++++ .history/main_20241107143645.go | 35 ++++++++++++ .history/main_20241107143705.go | 37 +++++++++++++ .history/main_20241107143710.go | 38 +++++++++++++ .history/main_20241107143716.go | 34 ++++++++++++ .history/main_20241107143739.go | 33 ++++++++++++ .history/main_20241107143812.go | 35 ++++++++++++ .history/main_20241107143814.go | 35 ++++++++++++ .history/main_20241107143819.go | 35 ++++++++++++ .history/main_20241107143833.go | 47 ++++++++++++++++ .history/main_20241107143838.go | 47 ++++++++++++++++ .history/main_20241107143858.go | 53 ++++++++++++++++++ .history/main_20241107144310.go | 54 +++++++++++++++++++ .history/main_20241107144313.go | 54 +++++++++++++++++++ .history/main_20241107144314.go | 54 +++++++++++++++++++ .history/main_20241107144321.go | 54 +++++++++++++++++++ .history/main_20241107145003.go | 54 +++++++++++++++++++ .history/main_20241107145004.go | 56 +++++++++++++++++++ .history/main_20241107145006.go | 56 +++++++++++++++++++ .history/main_20241107145009.go | 58 ++++++++++++++++++++ .history/main_20241107145013.go | 58 ++++++++++++++++++++ .history/main_20241107145015.go | 58 ++++++++++++++++++++ .history/main_20241107145018.go | 58 ++++++++++++++++++++ .history/main_20241107151310.go | 59 ++++++++++++++++++++ .history/main_20241107151311.go | 59 ++++++++++++++++++++ .history/main_20241107151314.go | 59 ++++++++++++++++++++ .history/main_20241126101419.go | 59 ++++++++++++++++++++ .history/main_20241126101424.go | 59 ++++++++++++++++++++ .history/main_20241126101430.go | 59 ++++++++++++++++++++ .history/main_20241126101433.go | 59 ++++++++++++++++++++ .history/main_20241126101435.go | 59 ++++++++++++++++++++ .history/main_20241126101550.go | 59 ++++++++++++++++++++ .history/main_20241126112832.go | 59 ++++++++++++++++++++ .history/main_20241126112836.go | 59 ++++++++++++++++++++ .history/main_20241126112845.go | 59 ++++++++++++++++++++ .history/main_20241126112852.go | 59 ++++++++++++++++++++ .history/main_20241126130838.go | 59 ++++++++++++++++++++ .history/main_20241127132020.go | 59 ++++++++++++++++++++ .history/main_20241127132022.go | 59 ++++++++++++++++++++ .history/main_20241127155330.go | 59 ++++++++++++++++++++ .history/main_20241128130857.go | 59 ++++++++++++++++++++ .history/main_20241128143954.go | 59 ++++++++++++++++++++ .history/main_20241128144051.go | 59 ++++++++++++++++++++ .history/main_20241128144053.go | 60 +++++++++++++++++++++ .history/main_20241128144058.go | 60 +++++++++++++++++++++ .history/main_20241128144101.go | 60 +++++++++++++++++++++ .history/main_20241128144104.go | 60 +++++++++++++++++++++ .history/main_20241128144317.go | 60 +++++++++++++++++++++ .history/main_20241128144319.go | 60 +++++++++++++++++++++ .history/main_20241128144329.go | 60 +++++++++++++++++++++ .history/main_20241128144331.go | 60 +++++++++++++++++++++ .history/main_20241128144504.go | 61 +++++++++++++++++++++ .history/main_20241128144509.go | 62 +++++++++++++++++++++ .history/main_20241128144549.go | 62 +++++++++++++++++++++ .history/main_20241128145829.go | 62 +++++++++++++++++++++ .history/main_20241128145830.go | 62 +++++++++++++++++++++ .history/main_20241128145833.go | 62 +++++++++++++++++++++ .history/main_20241128145842.go | 62 +++++++++++++++++++++ .history/main_20241128145854.go | 62 +++++++++++++++++++++ .history/main_20241202101616.go | 62 +++++++++++++++++++++ .history/main_20241202101619.go | 62 +++++++++++++++++++++ .history/main_20241202101621.go | 62 +++++++++++++++++++++ .history/main_20241202101624.go | 62 +++++++++++++++++++++ .history/main_20241202101636.go | 60 +++++++++++++++++++++ .history/main_20241202101845.go | 59 ++++++++++++++++++++ .history/main_20241202101848.go | 58 ++++++++++++++++++++ .history/main_20241202101911.go | 58 ++++++++++++++++++++ .history/main_20241202101916.go | 58 ++++++++++++++++++++ .history/main_20241202102519.go | 58 ++++++++++++++++++++ .history/main_20241202102520.go | 58 ++++++++++++++++++++ .history/main_20241202102530.go | 58 ++++++++++++++++++++ .history/main_20241202102531.go | 58 ++++++++++++++++++++ .history/main_20241202103035.go | 58 ++++++++++++++++++++ .history/main_20241202104241.go | 57 ++++++++++++++++++++ .history/main_20241202104245.go | 56 +++++++++++++++++++ agent-config.hcl | 64 ++++++++++++++++++++++ go.mod | 25 +++++++++ go.sum | 68 ++++++++++++++++++++++++ main.go | 56 +++++++++++++++++++ secrets.json | 1 + 105 files changed, 4844 insertions(+) create mode 100644 .history/agent-config_20241107145131.hcl create mode 100644 .history/agent-config_20241107145904.hcl create mode 100644 .history/agent-config_20241107145928.hcl create mode 100644 .history/main_20241107142952.go create mode 100644 .history/main_20241107143236.go create mode 100644 .history/main_20241107143239.go create mode 100644 .history/main_20241107143242.go create mode 100644 .history/main_20241107143247.go create mode 100644 .history/main_20241107143249.go create mode 100644 .history/main_20241107143252.go create mode 100644 .history/main_20241107143257.go create mode 100644 .history/main_20241107143258.go create mode 100644 .history/main_20241107143300.go create mode 100644 .history/main_20241107143506.go create mode 100644 .history/main_20241107143528.go create mode 100644 .history/main_20241107143534.go create mode 100644 .history/main_20241107143540.go create mode 100644 .history/main_20241107143541.go create mode 100644 .history/main_20241107143543.go create mode 100644 .history/main_20241107143546.go create mode 100644 .history/main_20241107143550.go create mode 100644 .history/main_20241107143556.go create mode 100644 .history/main_20241107143558.go create mode 100644 .history/main_20241107143600.go create mode 100644 .history/main_20241107143606.go create mode 100644 .history/main_20241107143644.go create mode 100644 .history/main_20241107143645.go create mode 100644 .history/main_20241107143705.go create mode 100644 .history/main_20241107143710.go create mode 100644 .history/main_20241107143716.go create mode 100644 .history/main_20241107143739.go create mode 100644 .history/main_20241107143812.go create mode 100644 .history/main_20241107143814.go create mode 100644 .history/main_20241107143819.go create mode 100644 .history/main_20241107143833.go create mode 100644 .history/main_20241107143838.go create mode 100644 .history/main_20241107143858.go create mode 100644 .history/main_20241107144310.go create mode 100644 .history/main_20241107144313.go create mode 100644 .history/main_20241107144314.go create mode 100644 .history/main_20241107144321.go create mode 100644 .history/main_20241107145003.go create mode 100644 .history/main_20241107145004.go create mode 100644 .history/main_20241107145006.go create mode 100644 .history/main_20241107145009.go create mode 100644 .history/main_20241107145013.go create mode 100644 .history/main_20241107145015.go create mode 100644 .history/main_20241107145018.go create mode 100644 .history/main_20241107151310.go create mode 100644 .history/main_20241107151311.go create mode 100644 .history/main_20241107151314.go create mode 100644 .history/main_20241126101419.go create mode 100644 .history/main_20241126101424.go create mode 100644 .history/main_20241126101430.go create mode 100644 .history/main_20241126101433.go create mode 100644 .history/main_20241126101435.go create mode 100644 .history/main_20241126101550.go create mode 100644 .history/main_20241126112832.go create mode 100644 .history/main_20241126112836.go create mode 100644 .history/main_20241126112845.go create mode 100644 .history/main_20241126112852.go create mode 100644 .history/main_20241126130838.go create mode 100644 .history/main_20241127132020.go create mode 100644 .history/main_20241127132022.go create mode 100644 .history/main_20241127155330.go create mode 100644 .history/main_20241128130857.go create mode 100644 .history/main_20241128143954.go create mode 100644 .history/main_20241128144051.go create mode 100644 .history/main_20241128144053.go create mode 100644 .history/main_20241128144058.go create mode 100644 .history/main_20241128144101.go create mode 100644 .history/main_20241128144104.go create mode 100644 .history/main_20241128144317.go create mode 100644 .history/main_20241128144319.go create mode 100644 .history/main_20241128144329.go create mode 100644 .history/main_20241128144331.go create mode 100644 .history/main_20241128144504.go create mode 100644 .history/main_20241128144509.go create mode 100644 .history/main_20241128144549.go create mode 100644 .history/main_20241128145829.go create mode 100644 .history/main_20241128145830.go create mode 100644 .history/main_20241128145833.go create mode 100644 .history/main_20241128145842.go create mode 100644 .history/main_20241128145854.go create mode 100644 .history/main_20241202101616.go create mode 100644 .history/main_20241202101619.go create mode 100644 .history/main_20241202101621.go create mode 100644 .history/main_20241202101624.go create mode 100644 .history/main_20241202101636.go create mode 100644 .history/main_20241202101845.go create mode 100644 .history/main_20241202101848.go create mode 100644 .history/main_20241202101911.go create mode 100644 .history/main_20241202101916.go create mode 100644 .history/main_20241202102519.go create mode 100644 .history/main_20241202102520.go create mode 100644 .history/main_20241202102530.go create mode 100644 .history/main_20241202102531.go create mode 100644 .history/main_20241202103035.go create mode 100644 .history/main_20241202104241.go create mode 100644 .history/main_20241202104245.go create mode 100644 agent-config.hcl create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go create mode 100644 secrets.json diff --git a/.history/agent-config_20241107145131.hcl b/.history/agent-config_20241107145131.hcl new file mode 100644 index 0000000..d1a05ff --- /dev/null +++ b/.history/agent-config_20241107145131.hcl @@ -0,0 +1,64 @@ +pid_file = "./pidfile" + +vault { + address = "https://openbao-fqdn:8200" + retry { + num_retries = 5 + } +} + +auto_auth { + method "kubernetes" { + config = { + role = "foobar" + } + } + + sink "file" { + config = { + path = "/tmp/file-foo" + } + } + + sink "file" { + wrap_ttl = "5m" + aad_env_var = "TEST_AAD_ENV" + dh_type = "curve25519" + dh_path = "/tmp/file-foo-dhpath2" + config = { + path = "/tmp/file-bar" + } + } +} + +cache { + // An empty cache stanza still enables caching +} + +api_proxy { + use_auto_auth_token = true +} + +listener "unix" { + address = "/path/to/socket" + tls_disable = true + + agent_api { + enable_quit = true + } +} + +listener "tcp" { + address = "127.0.0.1:8100" + tls_disable = true +} + +template { + source = "/etc/openbao/server.key.ctmpl" + destination = "/etc/openbao/server.key" +} + +template { + source = "/etc/openbao/server.crt.ctmpl" + destination = "/etc/openbao/server.crt" +} \ No newline at end of file diff --git a/.history/agent-config_20241107145904.hcl b/.history/agent-config_20241107145904.hcl new file mode 100644 index 0000000..cde3689 --- /dev/null +++ b/.history/agent-config_20241107145904.hcl @@ -0,0 +1,64 @@ +pid_file = "./pidfile" + +vault { + address = "https://localhost:8200" + retry { + num_retries = 5 + } +} + +auto_auth { + method "kubernetes" { + config = { + role = "foobar" + } + } + + sink "file" { + config = { + path = "/tmp/file-foo" + } + } + + sink "file" { + wrap_ttl = "5m" + aad_env_var = "TEST_AAD_ENV" + dh_type = "curve25519" + dh_path = "/tmp/file-foo-dhpath2" + config = { + path = "/tmp/file-bar" + } + } +} + +cache { + // An empty cache stanza still enables caching +} + +api_proxy { + use_auto_auth_token = true +} + +listener "unix" { + address = "/path/to/socket" + tls_disable = true + + agent_api { + enable_quit = true + } +} + +listener "tcp" { + address = "127.0.0.1:8100" + tls_disable = true +} + +template { + source = "/etc/openbao/server.key.ctmpl" + destination = "/etc/openbao/server.key" +} + +template { + source = "/etc/openbao/server.crt.ctmpl" + destination = "/etc/openbao/server.crt" +} \ No newline at end of file diff --git a/.history/agent-config_20241107145928.hcl b/.history/agent-config_20241107145928.hcl new file mode 100644 index 0000000..d1a05ff --- /dev/null +++ b/.history/agent-config_20241107145928.hcl @@ -0,0 +1,64 @@ +pid_file = "./pidfile" + +vault { + address = "https://openbao-fqdn:8200" + retry { + num_retries = 5 + } +} + +auto_auth { + method "kubernetes" { + config = { + role = "foobar" + } + } + + sink "file" { + config = { + path = "/tmp/file-foo" + } + } + + sink "file" { + wrap_ttl = "5m" + aad_env_var = "TEST_AAD_ENV" + dh_type = "curve25519" + dh_path = "/tmp/file-foo-dhpath2" + config = { + path = "/tmp/file-bar" + } + } +} + +cache { + // An empty cache stanza still enables caching +} + +api_proxy { + use_auto_auth_token = true +} + +listener "unix" { + address = "/path/to/socket" + tls_disable = true + + agent_api { + enable_quit = true + } +} + +listener "tcp" { + address = "127.0.0.1:8100" + tls_disable = true +} + +template { + source = "/etc/openbao/server.key.ctmpl" + destination = "/etc/openbao/server.key" +} + +template { + source = "/etc/openbao/server.crt.ctmpl" + destination = "/etc/openbao/server.crt" +} \ No newline at end of file diff --git a/.history/main_20241107142952.go b/.history/main_20241107142952.go new file mode 100644 index 0000000..e69de29 diff --git a/.history/main_20241107143236.go b/.history/main_20241107143236.go new file mode 100644 index 0000000..d9f4502 --- /dev/null +++ b/.history/main_20241107143236.go @@ -0,0 +1 @@ +pac \ No newline at end of file diff --git a/.history/main_20241107143239.go b/.history/main_20241107143239.go new file mode 100644 index 0000000..85f0393 --- /dev/null +++ b/.history/main_20241107143239.go @@ -0,0 +1 @@ +package main \ No newline at end of file diff --git a/.history/main_20241107143242.go b/.history/main_20241107143242.go new file mode 100644 index 0000000..7a7cee7 --- /dev/null +++ b/.history/main_20241107143242.go @@ -0,0 +1,3 @@ +package main + +main \ No newline at end of file diff --git a/.history/main_20241107143247.go b/.history/main_20241107143247.go new file mode 100644 index 0000000..e053a87 --- /dev/null +++ b/.history/main_20241107143247.go @@ -0,0 +1,3 @@ +package main + +func main \ No newline at end of file diff --git a/.history/main_20241107143249.go b/.history/main_20241107143249.go new file mode 100644 index 0000000..83cab73 --- /dev/null +++ b/.history/main_20241107143249.go @@ -0,0 +1,3 @@ +package main + +func main() \ No newline at end of file diff --git a/.history/main_20241107143252.go b/.history/main_20241107143252.go new file mode 100644 index 0000000..39c4c98 --- /dev/null +++ b/.history/main_20241107143252.go @@ -0,0 +1,5 @@ +package main + +func main(){ + +} \ No newline at end of file diff --git a/.history/main_20241107143257.go b/.history/main_20241107143257.go new file mode 100644 index 0000000..98c09d2 --- /dev/null +++ b/.history/main_20241107143257.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main(){ + fmt.Printl +} \ No newline at end of file diff --git a/.history/main_20241107143258.go b/.history/main_20241107143258.go new file mode 100644 index 0000000..b3aa75d --- /dev/null +++ b/.history/main_20241107143258.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main(){ + fmt.Println() +} \ No newline at end of file diff --git a/.history/main_20241107143300.go b/.history/main_20241107143300.go new file mode 100644 index 0000000..c3d0484 --- /dev/null +++ b/.history/main_20241107143300.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main(){ + fmt.Println("hello") +} \ No newline at end of file diff --git a/.history/main_20241107143506.go b/.history/main_20241107143506.go new file mode 100644 index 0000000..6f6d0e8 --- /dev/null +++ b/.history/main_20241107143506.go @@ -0,0 +1,8 @@ +package main + +import "fmt" +import openbao "github.com/openbao/openbao/api/v2" + +func main(){ + fmt.Println("hello") +} \ No newline at end of file diff --git a/.history/main_20241107143528.go b/.history/main_20241107143528.go new file mode 100644 index 0000000..98e87e6 --- /dev/null +++ b/.history/main_20241107143528.go @@ -0,0 +1,17 @@ +package main + +import "fmt" +import openbao "github.com/openbao/openbao/api/v2" + +func main(){ + config := openbao.DefaultConfig() + +config.Address = "http://127.0.0.1:8200" + +client, err := openbao.NewClient(config) +if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) +} + +client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143534.go b/.history/main_20241107143534.go new file mode 100644 index 0000000..d923e9e --- /dev/null +++ b/.history/main_20241107143534.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + config := openbao.DefaultConfig() + +config.Address = "http://127.0.0.1:8200" + +client, err := openbao.NewClient(config) +if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) +} + +client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143540.go b/.history/main_20241107143540.go new file mode 100644 index 0000000..162803a --- /dev/null +++ b/.history/main_20241107143540.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + config := openbao.DefaultConfig() + + config.Address = "http://127.0.0.1:8200" + +client, err := openbao.NewClient(config) +if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) +} + +client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143541.go b/.history/main_20241107143541.go new file mode 100644 index 0000000..b5d27fd --- /dev/null +++ b/.history/main_20241107143541.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + config := openbao.DefaultConfig() + + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) +if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) +} + +client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143543.go b/.history/main_20241107143543.go new file mode 100644 index 0000000..495efcb --- /dev/null +++ b/.history/main_20241107143543.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + config := openbao.DefaultConfig() + + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + +client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143546.go b/.history/main_20241107143546.go new file mode 100644 index 0000000..cb835e1 --- /dev/null +++ b/.history/main_20241107143546.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + config := openbao.DefaultConfig() + + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143550.go b/.history/main_20241107143550.go new file mode 100644 index 0000000..acbd66f --- /dev/null +++ b/.history/main_20241107143550.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143556.go b/.history/main_20241107143556.go new file mode 100644 index 0000000..53a65f0 --- /dev/null +++ b/.history/main_20241107143556.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143558.go b/.history/main_20241107143558.go new file mode 100644 index 0000000..54e6cd9 --- /dev/null +++ b/.history/main_20241107143558.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.P + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143600.go b/.history/main_20241107143600.go new file mode 100644 index 0000000..96c7398 --- /dev/null +++ b/.history/main_20241107143600.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println() + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143606.go b/.history/main_20241107143606.go new file mode 100644 index 0000000..f7b45a1 --- /dev/null +++ b/.history/main_20241107143606.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") +} \ No newline at end of file diff --git a/.history/main_20241107143644.go b/.history/main_20241107143644.go new file mode 100644 index 0000000..04eb7f2 --- /dev/null +++ b/.history/main_20241107143644.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") +} + +func writePassword(){ + +} \ No newline at end of file diff --git a/.history/main_20241107143645.go b/.history/main_20241107143645.go new file mode 100644 index 0000000..09aa833 --- /dev/null +++ b/.history/main_20241107143645.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") +} + +func writePassword(){ + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") +} \ No newline at end of file diff --git a/.history/main_20241107143705.go b/.history/main_20241107143705.go new file mode 100644 index 0000000..25c92b3 --- /dev/null +++ b/.history/main_20241107143705.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") +} + +func writePassword(){ + +} \ No newline at end of file diff --git a/.history/main_20241107143710.go b/.history/main_20241107143710.go new file mode 100644 index 0000000..ccfe62f --- /dev/null +++ b/.history/main_20241107143710.go @@ -0,0 +1,38 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") +} + +func writePassword(){ + +} \ No newline at end of file diff --git a/.history/main_20241107143716.go b/.history/main_20241107143716.go new file mode 100644 index 0000000..06d151a --- /dev/null +++ b/.history/main_20241107143716.go @@ -0,0 +1,34 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") +} diff --git a/.history/main_20241107143739.go b/.history/main_20241107143739.go new file mode 100644 index 0000000..49ee0b9 --- /dev/null +++ b/.history/main_20241107143739.go @@ -0,0 +1,33 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") +} diff --git a/.history/main_20241107143812.go b/.history/main_20241107143812.go new file mode 100644 index 0000000..80f7794 --- /dev/null +++ b/.history/main_20241107143812.go @@ -0,0 +1,35 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") +} diff --git a/.history/main_20241107143814.go b/.history/main_20241107143814.go new file mode 100644 index 0000000..627e03d --- /dev/null +++ b/.history/main_20241107143814.go @@ -0,0 +1,35 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") +} diff --git a/.history/main_20241107143819.go b/.history/main_20241107143819.go new file mode 100644 index 0000000..82cea4a --- /dev/null +++ b/.history/main_20241107143819.go @@ -0,0 +1,35 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") +} diff --git a/.history/main_20241107143833.go b/.history/main_20241107143833.go new file mode 100644 index 0000000..f0e047e --- /dev/null +++ b/.history/main_20241107143833.go @@ -0,0 +1,47 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") +if err != nil { + log.Fatalf("unable to read secret: %v", err) +} + +value, ok := secret.Data["password"].(string) +if !ok { +log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) +} +} diff --git a/.history/main_20241107143838.go b/.history/main_20241107143838.go new file mode 100644 index 0000000..63dc87b --- /dev/null +++ b/.history/main_20241107143838.go @@ -0,0 +1,47 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } +} diff --git a/.history/main_20241107143858.go b/.history/main_20241107143858.go new file mode 100644 index 0000000..54a1164 --- /dev/null +++ b/.history/main_20241107143858.go @@ -0,0 +1,53 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") +} diff --git a/.history/main_20241107144310.go b/.history/main_20241107144310.go new file mode 100644 index 0000000..f197af5 --- /dev/null +++ b/.history/main_20241107144310.go @@ -0,0 +1,54 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.P +} diff --git a/.history/main_20241107144313.go b/.history/main_20241107144313.go new file mode 100644 index 0000000..b34b7c6 --- /dev/null +++ b/.history/main_20241107144313.go @@ -0,0 +1,54 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println +} diff --git a/.history/main_20241107144314.go b/.history/main_20241107144314.go new file mode 100644 index 0000000..8c5516c --- /dev/null +++ b/.history/main_20241107144314.go @@ -0,0 +1,54 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println() +} diff --git a/.history/main_20241107144321.go b/.history/main_20241107144321.go new file mode 100644 index 0000000..a65e542 --- /dev/null +++ b/.history/main_20241107144321.go @@ -0,0 +1,54 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241107145003.go b/.history/main_20241107145003.go new file mode 100644 index 0000000..5255bb1 --- /dev/null +++ b/.history/main_20241107145003.go @@ -0,0 +1,54 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241107145004.go b/.history/main_20241107145004.go new file mode 100644 index 0000000..dbfc948 --- /dev/null +++ b/.history/main_20241107145004.go @@ -0,0 +1,56 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + + + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241107145006.go b/.history/main_20241107145006.go new file mode 100644 index 0000000..cacb23e --- /dev/null +++ b/.history/main_20241107145006.go @@ -0,0 +1,56 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241107145009.go b/.history/main_20241107145009.go new file mode 100644 index 0000000..9e34ebc --- /dev/null +++ b/.history/main_20241107145009.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241107145013.go b/.history/main_20241107145013.go new file mode 100644 index 0000000..66fa4e9 --- /dev/null +++ b/.history/main_20241107145013.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Print() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241107145015.go b/.history/main_20241107145015.go new file mode 100644 index 0000000..3452676 --- /dev/null +++ b/.history/main_20241107145015.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241107145018.go b/.history/main_20241107145018.go new file mode 100644 index 0000000..27251a8 --- /dev/null +++ b/.history/main_20241107145018.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241107151310.go b/.history/main_20241107151310.go new file mode 100644 index 0000000..61f408d --- /dev/null +++ b/.history/main_20241107151310.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241107151311.go b/.history/main_20241107151311.go new file mode 100644 index 0000000..bf152d1 --- /dev/null +++ b/.history/main_20241107151311.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main# +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241107151314.go b/.history/main_20241107151314.go new file mode 100644 index 0000000..edc2071 --- /dev/null +++ b/.history/main_20241107151314.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126101419.go b/.history/main_20241126101419.go new file mode 100644 index 0000000..9f7a35e --- /dev/null +++ b/.history/main_20241126101419.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://https://cnoe.localtest.me/openbao:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126101424.go b/.history/main_20241126101424.go new file mode 100644 index 0000000..c94c492 --- /dev/null +++ b/.history/main_20241126101424.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://cnoe.localtest.me/openbao:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126101430.go b/.history/main_20241126101430.go new file mode 100644 index 0000000..70450e5 --- /dev/null +++ b/.history/main_20241126101430.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://cnoe.localtest.me/openbao:8200:" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126101433.go b/.history/main_20241126101433.go new file mode 100644 index 0000000..ded6895 --- /dev/null +++ b/.history/main_20241126101433.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://cnoe.localtest.me/openbao:82" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126101435.go b/.history/main_20241126101435.go new file mode 100644 index 0000000..2549d1e --- /dev/null +++ b/.history/main_20241126101435.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://cnoe.localtest.me/openbao:80" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126101550.go b/.history/main_20241126101550.go new file mode 100644 index 0000000..edc2071 --- /dev/null +++ b/.history/main_20241126101550.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://127.0.0.1:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126112832.go b/.history/main_20241126112832.go new file mode 100644 index 0000000..c8dbb82 --- /dev/null +++ b/.history/main_20241126112832.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "https://cnoe.localtest.me/openbao" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126112836.go b/.history/main_20241126112836.go new file mode 100644 index 0000000..f207ec3 --- /dev/null +++ b/.history/main_20241126112836.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://cnoe.localtest.me/openbao" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126112845.go b/.history/main_20241126112845.go new file mode 100644 index 0000000..5f0a5f5 --- /dev/null +++ b/.history/main_20241126112845.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://cnoe.localtest.me/openbaos" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126112852.go b/.history/main_20241126112852.go new file mode 100644 index 0000000..f207ec3 --- /dev/null +++ b/.history/main_20241126112852.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://cnoe.localtest.me/openbao" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241126130838.go b/.history/main_20241126130838.go new file mode 100644 index 0000000..785a219 --- /dev/null +++ b/.history/main_20241126130838.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost/openbao" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241127132020.go b/.history/main_20241127132020.go new file mode 100644 index 0000000..38f68ee --- /dev/null +++ b/.history/main_20241127132020.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me/" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241127132022.go b/.history/main_20241127132022.go new file mode 100644 index 0000000..5de07f7 --- /dev/null +++ b/.history/main_20241127132022.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241127155330.go b/.history/main_20241127155330.go new file mode 100644 index 0000000..48ebbcb --- /dev/null +++ b/.history/main_20241127155330.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128130857.go b/.history/main_20241128130857.go new file mode 100644 index 0000000..ad9de5c --- /dev/null +++ b/.history/main_20241128130857.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128143954.go b/.history/main_20241128143954.go new file mode 100644 index 0000000..56a6e21 --- /dev/null +++ b/.history/main_20241128143954.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144051.go b/.history/main_20241128144051.go new file mode 100644 index 0000000..feec44f --- /dev/null +++ b/.history/main_20241128144051.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144053.go b/.history/main_20241128144053.go new file mode 100644 index 0000000..6325991 --- /dev/null +++ b/.history/main_20241128144053.go @@ -0,0 +1,60 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + dev-only-token + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144058.go b/.history/main_20241128144058.go new file mode 100644 index 0000000..238279d --- /dev/null +++ b/.history/main_20241128144058.go @@ -0,0 +1,60 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO")dev-only-token + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144101.go b/.history/main_20241128144101.go new file mode 100644 index 0000000..e8e8119 --- /dev/null +++ b/.history/main_20241128144101.go @@ -0,0 +1,60 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2(){ + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144104.go b/.history/main_20241128144104.go new file mode 100644 index 0000000..3439174 --- /dev/null +++ b/.history/main_20241128144104.go @@ -0,0 +1,60 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144317.go b/.history/main_20241128144317.go new file mode 100644 index 0000000..84d7f75 --- /dev/null +++ b/.history/main_20241128144317.go @@ -0,0 +1,60 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + // client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144319.go b/.history/main_20241128144319.go new file mode 100644 index 0000000..136b592 --- /dev/null +++ b/.history/main_20241128144319.go @@ -0,0 +1,60 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + // client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144329.go b/.history/main_20241128144329.go new file mode 100644 index 0000000..84d7f75 --- /dev/null +++ b/.history/main_20241128144329.go @@ -0,0 +1,60 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + // client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144331.go b/.history/main_20241128144331.go new file mode 100644 index 0000000..3439174 --- /dev/null +++ b/.history/main_20241128144331.go @@ -0,0 +1,60 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144504.go b/.history/main_20241128144504.go new file mode 100644 index 0000000..c1ba607 --- /dev/null +++ b/.history/main_20241128144504.go @@ -0,0 +1,61 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144509.go b/.history/main_20241128144509.go new file mode 100644 index 0000000..f4f9d74 --- /dev/null +++ b/.history/main_20241128144509.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client. + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128144549.go b/.history/main_20241128144549.go new file mode 100644 index 0000000..2fd68ac --- /dev/null +++ b/.history/main_20241128144549.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client.KVv2() + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128145829.go b/.history/main_20241128145829.go new file mode 100644 index 0000000..f4f9d74 --- /dev/null +++ b/.history/main_20241128145829.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client. + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128145830.go b/.history/main_20241128145830.go new file mode 100644 index 0000000..f4f9d74 --- /dev/null +++ b/.history/main_20241128145830.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client. + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128145833.go b/.history/main_20241128145833.go new file mode 100644 index 0000000..866137f --- /dev/null +++ b/.history/main_20241128145833.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client.Address() + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128145842.go b/.history/main_20241128145842.go new file mode 100644 index 0000000..f4f9d74 --- /dev/null +++ b/.history/main_20241128145842.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client. + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241128145854.go b/.history/main_20241128145854.go new file mode 100644 index 0000000..a49a852 --- /dev/null +++ b/.history/main_20241128145854.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://localhost:8200" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client.KVv1() + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202101616.go b/.history/main_20241202101616.go new file mode 100644 index 0000000..70f1ff0 --- /dev/null +++ b/.history/main_20241202101616.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://http://openbao.localtest.me/ui/" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client.KVv1() + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202101619.go b/.history/main_20241202101619.go new file mode 100644 index 0000000..e816396 --- /dev/null +++ b/.history/main_20241202101619.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me/ui/" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client.KVv1() + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202101621.go b/.history/main_20241202101621.go new file mode 100644 index 0000000..5b6947f --- /dev/null +++ b/.history/main_20241202101621.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client.KVv1() + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202101624.go b/.history/main_20241202101624.go new file mode 100644 index 0000000..5b6947f --- /dev/null +++ b/.history/main_20241202101624.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + client.KVv1() + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202101636.go b/.history/main_20241202101636.go new file mode 100644 index 0000000..e7efd14 --- /dev/null +++ b/.history/main_20241202101636.go @@ -0,0 +1,60 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202101845.go b/.history/main_20241202101845.go new file mode 100644 index 0000000..1e56684 --- /dev/null +++ b/.history/main_20241202101845.go @@ -0,0 +1,59 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202101848.go b/.history/main_20241202101848.go new file mode 100644 index 0000000..d925006 --- /dev/null +++ b/.history/main_20241202101848.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202101911.go b/.history/main_20241202101911.go new file mode 100644 index 0000000..a0cc92f --- /dev/null +++ b/.history/main_20241202101911.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-tokens") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202101916.go b/.history/main_20241202101916.go new file mode 100644 index 0000000..d925006 --- /dev/null +++ b/.history/main_20241202101916.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202102519.go b/.history/main_20241202102519.go new file mode 100644 index 0000000..972ec25 --- /dev/null +++ b/.history/main_20241202102519.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202102520.go b/.history/main_20241202102520.go new file mode 100644 index 0000000..ca4ce30 --- /dev/null +++ b/.history/main_20241202102520.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + // client.SetToken("dev-only-token") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202102530.go b/.history/main_20241202102530.go new file mode 100644 index 0000000..972ec25 --- /dev/null +++ b/.history/main_20241202102530.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202102531.go b/.history/main_20241202102531.go new file mode 100644 index 0000000..d925006 --- /dev/null +++ b/.history/main_20241202102531.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("dev-only-token") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202103035.go b/.history/main_20241202103035.go new file mode 100644 index 0000000..c2d8716 --- /dev/null +++ b/.history/main_20241202103035.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + // fmt.Println("hello there") + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("root") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202104241.go b/.history/main_20241202104241.go new file mode 100644 index 0000000..10b0a2a --- /dev/null +++ b/.history/main_20241202104241.go @@ -0,0 +1,57 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + // client.SetToken("s.javThgMSxCxyJbpS8sSNOPhO") + client.SetToken("root") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/.history/main_20241202104245.go b/.history/main_20241202104245.go new file mode 100644 index 0000000..37a25de --- /dev/null +++ b/.history/main_20241202104245.go @@ -0,0 +1,56 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("root") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/agent-config.hcl b/agent-config.hcl new file mode 100644 index 0000000..d1a05ff --- /dev/null +++ b/agent-config.hcl @@ -0,0 +1,64 @@ +pid_file = "./pidfile" + +vault { + address = "https://openbao-fqdn:8200" + retry { + num_retries = 5 + } +} + +auto_auth { + method "kubernetes" { + config = { + role = "foobar" + } + } + + sink "file" { + config = { + path = "/tmp/file-foo" + } + } + + sink "file" { + wrap_ttl = "5m" + aad_env_var = "TEST_AAD_ENV" + dh_type = "curve25519" + dh_path = "/tmp/file-foo-dhpath2" + config = { + path = "/tmp/file-bar" + } + } +} + +cache { + // An empty cache stanza still enables caching +} + +api_proxy { + use_auto_auth_token = true +} + +listener "unix" { + address = "/path/to/socket" + tls_disable = true + + agent_api { + enable_quit = true + } +} + +listener "tcp" { + address = "127.0.0.1:8100" + tls_disable = true +} + +template { + source = "/etc/openbao/server.key.ctmpl" + destination = "/etc/openbao/server.key" +} + +template { + source = "/etc/openbao/server.crt.ctmpl" + destination = "/etc/openbao/server.crt" +} \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6cbc565 --- /dev/null +++ b/go.mod @@ -0,0 +1,25 @@ +module main + +go 1.23.2 + +require ( + github.com/cenkalti/backoff/v3 v3.0.0 // indirect + github.com/go-jose/go-jose/v3 v3.0.1 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/go-retryablehttp v0.7.7 // indirect + github.com/hashicorp/go-rootcerts v1.0.2 // indirect + github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6 // indirect + github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect + github.com/hashicorp/go-sockaddr v1.0.2 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/openbao/openbao/api/v2 v2.0.1 // indirect + github.com/ryanuber/go-glob v1.0.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/text v0.14.0 // indirect + golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..94e5c3d --- /dev/null +++ b/go.sum @@ -0,0 +1,68 @@ +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/cenkalti/backoff/v3 v3.0.0 h1:ske+9nBpD9qZsTBoF41nW5L+AIuFBKMeze18XQ3eG1c= +github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA= +github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU= +github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk= +github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6 h1:om4Al8Oy7kCm/B86rLCLah4Dt5Aa0Fr5rYBG60OzwHQ= +github.com/hashicorp/go-secure-stdlib/parseutil v0.1.6/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8= +github.com/hashicorp/go-secure-stdlib/strutil v0.1.1/go.mod h1:gKOamz3EwoIoJq7mlMIRBpVTAUn8qPCrEclOKKWhD3U= +github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9CdjCtrXrXGuOpxEA7Ts= +github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4= +github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= +github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/openbao/openbao/api/v2 v2.0.1 h1:oyDqLa8m+XY3YBbgQ4YnX5o+/4/ybShiDPMC/7WomtE= +github.com/openbao/openbao/api/v2 v2.0.1/go.mod h1:qIp3G8D5vaW+r7TG2YoCCEo/5HxTvidwZA0GiwA1iJ8= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= +github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 h1:NusfzzA6yGQ+ua51ck7E3omNUX/JuqbFSaRGqU8CcLI= +golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go new file mode 100644 index 0000000..37a25de --- /dev/null +++ b/main.go @@ -0,0 +1,56 @@ +package main + +import ( + "context" + "fmt" + "log" + + openbao "github.com/openbao/openbao/api/v2" +) + +func main() { + main2() +} + +func main2() { + fmt.Println("Connecting...") + config := openbao.DefaultConfig() + config.Address = "http://openbao.localtest.me" + + client, err := openbao.NewClient(config) + if err != nil { + log.Fatalf("unable to initialize OpenBao client: %v", err) + } + + client.SetToken("root") + + // Writing a secret + secretData := map[string]interface{}{ + "password": "OpenBao123", + } + + _, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData) + if err != nil { + log.Fatalf("unable to write secret: %v", err) + } + + fmt.Println("Secret written successfully.") + + // Retrieving a secret + secret, err := client.KVv2("secret").Get(context.Background(), "my-secret-password") + if err != nil { + log.Fatalf("unable to read secret: %v", err) + } + + value, ok := secret.Data["password"].(string) + if !ok { + log.Fatalf("value type assertion failed: %T %#v", secret.Data["password"], secret.Data["password"]) + } + + if value != "OpenBao123" { + log.Fatalf("unexpected password value %q retrieved from openbao", value) + } + + fmt.Println("Access granted!") + fmt.Println(value) +} diff --git a/secrets.json b/secrets.json new file mode 100644 index 0000000..0b5a58c --- /dev/null +++ b/secrets.json @@ -0,0 +1 @@ +{"request_id":"6896e8ae-6ff4-14a8-d19a-1ab3f436d36f","lease_id":"","renewable":false,"lease_duration":0,"data":{"data":{"password":"OpenBao123"},"metadata":{"created_time":"2024-12-02T09:30:38.217039764Z","custom_metadata":null,"deletion_time":"","destroyed":false,"version":1}},"wrap_info":null,"warnings":null,"auth":null}