Manage OpenArtifact Keycloak SSO and publish its client credential to Vaultwarden
Update Kubernetes Services Wiki / Generate and Update K8s Wiki (push) Successful in 7s
Keycloak Terraform / Terraform (push) Failing after 21s

This commit is contained in:
Aleksandr Bogomiakov committed 2026-11-24 20:15:33 +02:00
1 parent cabc9b167a
commit dd591ecd1d
11 files changed
+208 -1

No files matched your search

+23
View File
@@ -49,3 +49,26 @@ provider "registry.terraform.io/keycloak/keycloak" {
"zh:f57319d9a7ac387d5070c909fd0084ccfc296f1f3193efde995ae24aa1729a39",
]
}
provider "registry.terraform.io/maxlaverse/bitwarden" {
version = "0.23.0"
constraints = "0.23.0"
hashes = [
"h1:rGw+VwEbPnaUlT61GdMDFFLOPonrZ75/Y1fvlykkLyQ=",
"h1:vX8Ov0YGlR7vlJNFMZkqRcKuS/+SKDkNianb1ogIzCU=",
"zh:14a4b8900a58c2b3e829d7f12ac7e180c3885fa6be7ec7741beb18bf7ff4287f",
"zh:27b8830f6071f23081ee8afb6b3724ff6d146a871d8d5d97ec8697fedb3accd8",
"zh:3fbeada2810a4b069984b1d54d5c0b6b98b025a90690c3bcabe691aff8111323",
"zh:415fe80a7d80d1830812dcc1a42ceedfee2998ea3cf91c3d2d089f7e7f6cc5cc",
"zh:41e0e4964ab5906868e9976c75ef3169881290f253d19e494bdd7f7c012052b2",
"zh:5e217a3a46ea4a58be3fc8cb4b5fef1b0bebf3499ceda41ff094f3c1a5417aa0",
"zh:89f7ef1ec3b56873fc24ebcd88ddf7ef82195e5ac8172b5828c58336102ce3ee",
"zh:8df088984a2aee5466321c4ae75efd9250b6c06b6f66a6db5b6bd170c1cf2fd6",
"zh:98944e414519c7e9a7d7fcf0793ca1f50af35e685bec26ea323b09e3668fa5be",
"zh:a63e6c56918011bf1340ac4ddb89dc6a5fad29202beb235f0c9c546f3dc7427b",
"zh:d70d868ed09999fde1f11ac78f60b674a5d787dbaaa3e539a5dfb3192a3cedc5",
"zh:df794e4eb1bfc7c7e752ff59f61e95784526f84e0341694b38d54b2ea7c83b16",
"zh:f809ab383cca0a5f83072981c64208cbd7fa67e986a86ee02dd2c82333221e32",
"zh:ff919bc4dda39d8879bf9d659d61ec02ed65908781cf220cfb9a7265d360aea4",
]
}
+11 -1
View File
@@ -274,6 +274,16 @@ resource "keycloak_openid_client" "oauth2_app" {
access_token_lifespan = each.value.access_token_lifespan
}
resource "bitwarden_item_login" "oauth2_app" {
for_each = { for key, app in var.oauth2_applications : key => app if app.publish_to_vaultwarden }
name = "keycloak/${each.key}"
username = keycloak_openid_client.oauth2_app[each.key].client_id
password = keycloak_openid_client.oauth2_app[each.key].client_secret
organization_id = var.vaultwarden_organization_id
collection_ids = [var.vaultwarden_collection_id]
}
resource "keycloak_openid_group_membership_protocol_mapper" "oauth2_app_groups" {
for_each = var.oauth2_applications
@@ -281,7 +291,7 @@ resource "keycloak_openid_group_membership_protocol_mapper" "oauth2_app_groups"
client_id = keycloak_openid_client.oauth2_app[each.key].id
name = "groups"
claim_name = "groups"
full_path = false
full_path = each.value.group_full_path
}
resource "keycloak_openid_client_default_scopes" "oauth2_app" {
+9
View File
@@ -4,6 +4,10 @@ terraform {
source = "keycloak/keycloak"
version = ">= 5.0.0"
}
bitwarden = {
source = "maxlaverse/bitwarden"
version = "= 0.23.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.0.0"
@@ -22,3 +26,8 @@ provider "kubernetes" {
# CI supplies the current cluster context through its KUBECONFIG secret.
config_path = "~/.kube/config"
}
provider "bitwarden" {
server = "https://vw.hexor.cy"
client_implementation = "embedded"
}
+7
View File
@@ -34,6 +34,13 @@ proxy_applications = {
}
oauth2_applications = {
openartifact = {
redirect_uris = ["https://repo.hexor.cy/api/v1/auth/sso/oidc/keycloak/callback"]
web_origins = ["https://repo.hexor.cy"]
post_logout_redirect_uris = ["https://repo.hexor.cy/login"]
group_full_path = true
publish_to_vaultwarden = true
}
gitea = {
redirect_uris = ["https://gt.hexor.cy/user/oauth2/Keycloak/callback"]
web_origins = ["https://gt.hexor.cy"]
+20
View File
@@ -51,7 +51,27 @@ variable "oauth2_applications" {
extra_default_scopes = optional(list(string), [])
extra_optional_scopes = optional(list(string), [])
allowed_groups = optional(list(string), [])
group_full_path = optional(bool, false)
publish_to_vaultwarden = optional(bool, false)
access_token_lifespan = optional(string) # seconds; null keeps the realm default
}))
default = {}
}
variable "vaultwarden_organization_id" {
description = "Vaultwarden organization receiving published Keycloak client credentials"
type = string
validation {
condition = can(regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", var.vaultwarden_organization_id))
error_message = "Set the UUID of the target Vaultwarden organization."
}
}
variable "vaultwarden_collection_id" {
description = "Vaultwarden collection shared by the Terraform writer and application secret reader"
type = string
validation {
condition = can(regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", var.vaultwarden_collection_id))
error_message = "Set the UUID of the target Vaultwarden collection."
}
}