title | description |
---|---|
HashiCorp Vault Integration - OIDC with KeyCloak |
HashiCorp Vault Integration OIDC Authentication with KeyCloak |
- HashiCorp Vault
- KeyCloak
- PostgreSQL
- TerraForm
- Optional: Identity Aware Proxy (IAP)
This repo walks through how to set up Vault and Keycloak for OIDC Authentication.
- HCLIC: You will need to provide your own Vault Enterprise License File
- Place your
vault.hclic
in theroot
of this repo when you execute your setup and configurations viamake
- Place your
- Sequence:
- (Optional) Clone and Link Vault and Keycloak Repos
./docker-vault
./docker-keycloak
- (Optional) Spin up Vault and Keycloak (along with PostgreSQL)
- Configure Vault and Keycloak for OIDC
./integration
- Requirements:
- Vault URL
- Vault Token
- Keycloak URL
- Keycloak User
- Keycloak Password
- You may need to manually edit the
./integrations/terraform/terraform.auto.tfvars
or other environment variables if you're not using the local Docker instances of Vault and Keycloak.
- (Optional) Clone and Link Vault and Keycloak Repos
KEY | DEFAULT |
---|---|
vault_url |
http://localhost:8200 |
keycloak_url |
http://localhost:8080 |
vault_root_token |
cat docker-vault/terraform/data/scripts/vault.json | jq -r '.root_token' |
keycloak_user |
admin |
keycloak_password |
passw0rd |
If you already have a Vault and Keycloak environment running somewhere, you just need to set your environment variables with the relevant inputs.
make -f Makefile integrate-only
make -f Makefile clean-integrate
Instantiate Vault and Keycloak then integrate OIDC between the two platforms.
make -f Makefile testbed-all
make -f Makefile clean-all
.
├── LICENSE
├── Makefile
├── README.md
├── assets
├── docker-keycloak -> ./tmp/testbed-docker-keycloak/docker-keycloak
├── docker-vault -> ./tmp/hcp-vault-docker-enterprise/docker-vault
├── integration
│ ├── Makefile
│ ├── docker-compose
│ │ └── vault-agent
│ └── terraform
│ ├── 00.variables.tf
│ ├── 00.versions.tf
│ ├── 01.keycloak.tf
│ ├── 01.vault.tf
│ ├── 99.outputs.tf
│ ├── templates
│ │ ├── app1_owner_policy.tpl
│ │ ├── app1_reader_policy.tpl
│ │ ├── app2_owner_policy.tpl
│ │ ├── app2_reader_policy.tpl
│ │ ├── vault_admin_policy.tpl
│ │ └── vault_super_admin_policy.tpl
│ ├── terraform.auto.tfvars
│ ├── terraform.tfstate
│ └── terraform.tfstate.backup
├── terraform.tfstate
├── utility
└── vault.hclic
ENTITY | PASSWORD | KEYCLOAK REALM | KEYCLOAK ROLE | VAULT NAMESPACE | VAULT POLICY |
---|---|---|---|---|---|
alice | alice | demo | vault_super_admin_role |
root, demo | vault_super_admin_policy.tpl |
bob | bob | demo | vault_admin_role |
root, demo | vault_admin_policy.tpl |
carol | carol | demo | app1_owner_role |
root, demo | app1_owner_policy.tpl |
dan | dan | demo | app2_owner_role |
root, demo | app2_owner_policy.tpl |
CONTAINER | NETWORK | IP | PORT-INTERNAL | PORT-EXTERNAL |
---|---|---|---|---|
vault_s1 | vault-ent-network | 10.88.0.18 | 8200 | 8200 |
vault_s2 | vault-ent-network | 10.88.0.28 | 8200 | 28200 |
vautl_s3 | vault-ent-network | 10.88.0.38 | 8200 | 38200 |
keycloak | vault-ent-network | 10.88.0.100 | 8080 | 8080 |
postgresql | vault-ent-network | 10.88.0.101 | 5432 | 5432 |
Name | Version |
---|---|
terraform | >= 0.13 |
keycloak | >= 3.0.0 |
vault | >= 3.0.0 |
Name | Version |
---|---|
keycloak | 4.4.0 |
vault | 3.25.0 |
No modules.
Name | Description | Type | Default | Required |
---|---|---|---|---|
keycloak_password | Keycloak Password | string |
"" |
no |
keycloak_url | Keycloak URL | string |
"http://keycloak:8080" |
no |
keycloak_user | Keycloak User | string |
"" |
no |
vault_root_token | Vault Root Token | string |
"" |
no |
vault_url | Vault URL | string |
"http://localhost:8200" |
no |
No outputs.
- https://openid.net/developers/how-connect-works/
- https://openid.net/specs/openid-connect-basic-1_0.html
- https://developer.okta.com/docs/concepts/oauth-openid/
- https://developer.hashicorp.com/vault/docs/auth/jwt
- https://developer.hashicorp.com/vault/docs/auth/jwt/oidc-providers/keycloak
- https://developer.hashicorp.com/vault/api-docs/auth/jwt
- https://www.keycloak.org/server/configuration
- https://www.keycloak.org/getting-started/getting-started-docker
- https://en.wikipedia.org/wiki/Alice_and_Bob
- https://jwt.io/
- https://github.com/nicklhw/vault-keycloak
Thanks to @nicklhw