2021-12-26 01:08:03 +01:00
|
|
|
# Configure TVL Keycloak instance.
|
|
|
|
#
|
|
|
|
# TODO(tazjin): Configure GitHub/GitLab IDP
|
|
|
|
|
|
|
|
terraform {
|
|
|
|
required_providers {
|
|
|
|
keycloak = {
|
|
|
|
source = "mrparkers/keycloak"
|
|
|
|
}
|
|
|
|
}
|
2021-12-27 15:23:59 +01:00
|
|
|
|
|
|
|
backend "s3" {
|
|
|
|
endpoint = "https://objects.dc-sto1.glesys.net"
|
|
|
|
bucket = "tvl-state"
|
|
|
|
key = "terraform/tvl-keycloak"
|
|
|
|
region = "glesys"
|
|
|
|
|
|
|
|
skip_credentials_validation = true
|
|
|
|
skip_region_validation = true
|
|
|
|
skip_metadata_api_check = true
|
|
|
|
}
|
2021-12-26 01:08:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
provider "keycloak" {
|
|
|
|
client_id = "terraform"
|
|
|
|
url = "https://auth.tvl.fyi"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "keycloak_realm" "tvl" {
|
|
|
|
realm = "TVL"
|
|
|
|
enabled = true
|
|
|
|
display_name = "The Virus Lounge"
|
|
|
|
default_signature_algorithm = "RS256"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "keycloak_ldap_user_federation" "tvl_ldap" {
|
|
|
|
name = "tvl-ldap"
|
|
|
|
realm_id = keycloak_realm.tvl.id
|
|
|
|
enabled = true
|
|
|
|
connection_url = "ldap://localhost"
|
|
|
|
users_dn = "ou=users,dc=tvl,dc=fyi"
|
|
|
|
username_ldap_attribute = "cn"
|
|
|
|
uuid_ldap_attribute = "cn"
|
|
|
|
rdn_ldap_attribute = "cn"
|
|
|
|
full_sync_period = 86400
|
2021-12-26 17:07:49 +01:00
|
|
|
trust_email = true
|
2021-12-26 01:08:03 +01:00
|
|
|
|
|
|
|
user_object_classes = [
|
|
|
|
"inetOrgPerson",
|
|
|
|
"organizationalPerson",
|
|
|
|
]
|
|
|
|
}
|
2021-12-26 16:36:00 +01:00
|
|
|
|
|
|
|
resource "keycloak_openid_client" "oauth2_proxy" {
|
|
|
|
realm_id = keycloak_realm.tvl.id
|
|
|
|
client_id = "oauth2-proxy"
|
|
|
|
name = "TVL OAuth2 Proxy"
|
|
|
|
enabled = true
|
|
|
|
access_type = "CONFIDENTIAL"
|
|
|
|
standard_flow_enabled = true
|
|
|
|
|
|
|
|
valid_redirect_uris = [
|
2021-12-26 17:08:14 +01:00
|
|
|
"https://login.tvl.fyi/oauth2/callback",
|
|
|
|
"http://localhost:4774/oauth2/callback",
|
2021-12-26 16:36:00 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2021-12-26 17:08:14 +01:00
|
|
|
resource "keycloak_openid_audience_protocol_mapper" "oauth2_proxy_audience" {
|
|
|
|
realm_id = keycloak_realm.tvl.id
|
|
|
|
client_id = keycloak_openid_client.oauth2_proxy.id
|
|
|
|
name = "oauth2-proxy-audience"
|
|
|
|
included_custom_audience = keycloak_openid_client.oauth2_proxy.client_id
|
2021-12-26 16:36:00 +01:00
|
|
|
}
|
2021-12-27 14:40:39 +01:00
|
|
|
|
|
|
|
resource "keycloak_openid_client" "grafana" {
|
|
|
|
realm_id = keycloak_realm.tvl.id
|
|
|
|
client_id = "grafana"
|
|
|
|
name = "Grafana"
|
|
|
|
enabled = true
|
|
|
|
access_type = "CONFIDENTIAL"
|
|
|
|
standard_flow_enabled = true
|
|
|
|
base_url = "https://status.tvl.su"
|
|
|
|
|
|
|
|
valid_redirect_uris = [
|
|
|
|
"https://status.tvl.su/*",
|
|
|
|
]
|
|
|
|
}
|
2021-12-27 15:33:37 +01:00
|
|
|
|
|
|
|
resource "keycloak_openid_client" "gerrit" {
|
|
|
|
realm_id = keycloak_realm.tvl.id
|
|
|
|
client_id = "gerrit"
|
|
|
|
name = "TVL Gerrit"
|
|
|
|
enabled = true
|
|
|
|
access_type = "CONFIDENTIAL"
|
|
|
|
standard_flow_enabled = true
|
|
|
|
base_url = "https://cl.tvl.fyi"
|
|
|
|
description = "TVL's code review tool"
|
|
|
|
direct_access_grants_enabled = true
|
|
|
|
exclude_session_state_from_auth_response = false
|
|
|
|
|
|
|
|
valid_redirect_uris = [
|
|
|
|
"https://cl.tvl.fyi/*",
|
|
|
|
]
|
|
|
|
|
|
|
|
web_origins = [
|
|
|
|
"https://cl.tvl.fyi",
|
|
|
|
]
|
|
|
|
}
|
2021-12-27 15:38:14 +01:00
|
|
|
|
2021-12-28 13:38:33 +01:00
|
|
|
resource "keycloak_saml_client" "buildkite" {
|
|
|
|
realm_id = keycloak_realm.tvl.id
|
|
|
|
client_id = "https://buildkite.com"
|
|
|
|
name = "Buildkite"
|
|
|
|
base_url = "https://buildkite.com/sso/tvl"
|
|
|
|
|
|
|
|
client_signature_required = false
|
|
|
|
assertion_consumer_post_url = "https://buildkite.com/sso/~/1531aca5-f49c-4151-8832-a451e758af4c/saml/consume"
|
2021-12-27 15:38:14 +01:00
|
|
|
|
|
|
|
valid_redirect_uris = [
|
2021-12-28 13:38:33 +01:00
|
|
|
"https://buildkite.com/sso/~/1531aca5-f49c-4151-8832-a451e758af4c/saml/consume"
|
2021-12-27 15:38:14 +01:00
|
|
|
]
|
2021-12-28 13:38:33 +01:00
|
|
|
}
|
2021-12-27 15:38:14 +01:00
|
|
|
|
2021-12-28 13:38:33 +01:00
|
|
|
resource "keycloak_saml_user_attribute_protocol_mapper" "buildkite_email" {
|
|
|
|
realm_id = keycloak_realm.tvl.id
|
|
|
|
client_id = keycloak_saml_client.buildkite.id
|
|
|
|
name = "buildkite-email-mapper"
|
|
|
|
user_attribute = "email"
|
|
|
|
saml_attribute_name = "email"
|
|
|
|
saml_attribute_name_format = "Unspecified"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "keycloak_saml_user_attribute_protocol_mapper" "buildkite_name" {
|
|
|
|
realm_id = keycloak_realm.tvl.id
|
|
|
|
client_id = keycloak_saml_client.buildkite.id
|
|
|
|
name = "buildkite-name-mapper"
|
|
|
|
user_attribute = "displayName"
|
|
|
|
saml_attribute_name = "name"
|
|
|
|
saml_attribute_name_format = "Unspecified"
|
2021-12-27 15:38:14 +01:00
|
|
|
}
|