Skip to content

Instantly share code, notes, and snippets.

@42wim

42wim/main.go Secret

Created June 24, 2023 15:38
Show Gist options
  • Save 42wim/e97d4dbf9d61ccfe436f535660d9c069 to your computer and use it in GitHub Desktop.
Save 42wim/e97d4dbf9d61ccfe436f535660d9c069 to your computer and use it in GitHub Desktop.
vault jwt
package main
import (
"time"
jwtauth "github.com/hashicorp/vault-plugin-auth-jwt"
vaultapi "github.com/hashicorp/vault/api"
)
func main() {
for {
authOIDC("avalidrole")
time.Sleep(30 * time.Second)
}
}
func authOIDC(role string) {
config := vaultapi.DefaultConfig()
config.Address = "https://yourvaultserver"
c, err := vaultapi.NewClient(config)
if err != nil {
panic(err)
}
j := &jwtauth.CLIHandler{}
m := make(map[string]string)
m["role"] = role
_, err = j.Auth(c, m)
if err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment