-
-
Save 42wim/e97d4dbf9d61ccfe436f535660d9c069 to your computer and use it in GitHub Desktop.
vault jwt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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