In kubernetes community usage of golang is high and lot of projects are written in this language. It would be nice if SDK would support golang.
While there are currently no bindings for golang, it should be possible with some work to use cgo to have interoperability with the bitwarden_c
crate.
The bitwarden_c
crate exposes a c compatible library with three methods, init
, run_command
and free
, sdk/c.rs at master · bitwarden/sdk · GitHub. There is a C# example which showcases how to use these methods, but in short run_command
exposes a json interface. It should be possible to generate JSON bindings from the SDKs json schemas.
I created a small package that gets items from a local Bitwarden server. I personally use it for scripts where I don’t want to hardcode credentials. It could also be used (at your own risk) in production too. You could even run the Bitwarden client server from its own Docker container if you’d like.
For anyone who is interested, you can find it here: GitHub - floriaanpost/bitwarden: Bitwarden from Go
it looks like there is an sdk for go now, but trying to compile it gives an error.
/usr/lib/golang/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/bin/ld: /home/waf/go/pkg/mod/github.com/bitwarden/[email protected]/internal/cinterface/lib/linux-x64/libbitwarden_c.a(bitwarden_c.tokio-3c56ba4e3c4aa90a.tokio.db699ad6e67f3ec9-cgu.0.rcgu.o.rcgu.o): in function `tokio::runtime::scheduler::multi_thread::worker::run':
tokio.db699ad6e67f3ec9-cgu.0:(.text._ZN5tokio7runtime9scheduler12multi_thread6worker3run17h40b487d4e81f7731E+0x692): undefined reference to `pow'
/bin/ld: tokio.db699ad6e67f3ec9-cgu.0:(.text._ZN5tokio7runtime9scheduler12multi_thread6worker3run17h40b487d4e81f7731E+0xc95): undefined reference to `pow'
/bin/ld: /home/waf/go/pkg/mod/github.com/bitwarden/[email protected]/internal/cinterface/lib/linux-x64/libbitwarden_c.a(bitwarden_c.num_cpus-48d8c06d94ff50f9.num_cpus.baa012fa3dfb01b7-cgu.0.rcgu.o.rcgu.o): in function `std::sys::sync::once::futex::Once::call':
num_cpus.baa012fa3dfb01b7-cgu.0:(.text.unlikely._ZN3std3sys4sync4once5futex4Once4call17h8448e83b91b21622E.llvm.16575399225377328621+0x15de): undefined reference to `ceil'
collect2: error: ld returned 1 exit status
On MacOS I also can’t build the bws sdk module, I get
# github.com/bitwarden/sdk/languages/go
./command_runner.go:10:21: undefined: Command
./project.go:4:47: undefined: ProjectResponse
./project.go:5:32: undefined: ProjectsResponse
./project.go:6:26: undefined: ProjectResponse
./project.go:7:65: undefined: ProjectResponse
./project.go:8:32: undefined: ProjectsDeleteResponse
./secrets.go:4:80: undefined: SecretResponse
./secrets.go:5:32: undefined: SecretIdentifiersResponse
./secrets.go:6:25: undefined: SecretResponse
./secrets.go:7:33: undefined: SecretsResponse
./secrets.go:7:33: too many errors
and I can’t submit a bug report on github, the submit button is inactive