Skip to content

Commit

Permalink
Vault OIDC patching (#203)
Browse files Browse the repository at this point in the history
* telemetry adjustments

* apply oidc patched values for vault redirect uris
  • Loading branch information
johndietz committed Aug 9, 2022
1 parent d329bcf commit b9fe7be
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func ConfigureVault(dryRun bool, bootstrapOnly bool) {
// ```
// ... obviously keep the sensitive values bound to vars

if bootstrapOnly {
viper.Set("vault.oidc_redirect_uris", "will-be-patched-later")
}

vaultToken := viper.GetString("vault.token")
var kPortForwardOutb, kPortForwardErrb bytes.Buffer
kPortForward := exec.Command(config.KubectlClientPath, "--kubeconfig", config.KubeConfigPath, "-n", "vault", "port-forward", "svc/vault", "8200:8200")
Expand Down Expand Up @@ -88,8 +92,7 @@ func ConfigureVault(dryRun bool, bootstrapOnly bool) {
envs["TF_VAR_hosted_zone_id"] = viper.GetString("aws.domainid")
envs["TF_VAR_hosted_zone_name"] = viper.GetString("aws.hostedzonename")
envs["TF_VAR_vault_token"] = vaultToken
envs["TF_VAR_vault_redirect_uris"] = "[\"will-be-patched-later\"]"

envs["TF_VAR_vault_redirect_uris"] = viper.GetString("vault.oidc_redirect_uris")
directory := fmt.Sprintf("%s/gitops/terraform/vault", config.K1FolderPath)
err = os.Chdir(directory)
if err != nil {
Expand Down Expand Up @@ -141,6 +144,9 @@ func AddGitlabOidcApplications(dryRun bool) {
cb["argo"] = fmt.Sprintf("https://argo.%s/oauth2/callback", domain)
cb["argocd"] = fmt.Sprintf("https://argocd.%s/auth/callback", domain)
cb["vault"] = fmt.Sprintf("https://vault.%s:8250/oidc/callback http://localhost:8250/oidc/callback https://vault.%s/ui/vault/auth/oidc/oidc/callback http://localhost:8200/ui/vault/auth/oidc/oidc/callback", domain, domain)

viper.Set("vault.oidc_redirect_uris", cb["vault"])
viper.WriteConfig()

for _, app := range apps {
log.Println("checking to see if", app, "oidc application needs to be created in gitlab")
Expand Down

0 comments on commit b9fe7be

Please sign in to comment.