added auth-proxy dashboard
Check with kubeconform / lint (push) Successful in 8s
Update Kubernetes Services Wiki / Generate and Update K8s Wiki (push) Successful in 13s
Auto-update README / Generate README and Create MR (push) Successful in 11s

This commit is contained in:
Ultradesu
2026-05-05 18:57:05 +01:00
parent cdf836afd3
commit cd45c64457
5 changed files with 123 additions and 59 deletions
+68 -43
View File
@@ -92,48 +92,6 @@ resource "keycloak_openid_client_default_scopes" "rsauth2_proxy" {
] ]
} }
# =============================================================================
# rsauth2-proxy client (localhost testing)
# =============================================================================
resource "keycloak_openid_client" "rsauth2_proxy_dev" {
realm_id = keycloak_realm.hexor.id
client_id = "rsauth2-proxy-dev"
name = "rsauth2-proxy (dev)"
enabled = true
access_type = "CONFIDENTIAL"
standard_flow_enabled = true
direct_access_grants_enabled = false
valid_redirect_uris = [
"http://localhost:8080/callback",
]
web_origins = [
"http://localhost:8080",
]
}
resource "keycloak_openid_group_membership_protocol_mapper" "rsauth2_proxy_dev_groups" {
realm_id = keycloak_realm.hexor.id
client_id = keycloak_openid_client.rsauth2_proxy_dev.id
name = "groups"
claim_name = "groups"
full_path = false
}
resource "keycloak_openid_client_default_scopes" "rsauth2_proxy_dev" {
realm_id = keycloak_realm.hexor.id
client_id = keycloak_openid_client.rsauth2_proxy_dev.id
default_scopes = [
"openid",
"profile",
"email",
]
}
# ============================================================================= # =============================================================================
# Proxy applications — auto-created groups + routes ConfigMap # Proxy applications — auto-created groups + routes ConfigMap
# ============================================================================= # =============================================================================
@@ -154,7 +112,74 @@ locals {
} }
} }
resource "kubernetes_config_map" "auth_proxy_routes" { # =============================================================================
# OAuth2 applications — full OIDC clients for apps that handle auth themselves
# =============================================================================
resource "keycloak_openid_client" "oauth2_app" {
for_each = var.oauth2_applications
realm_id = keycloak_realm.hexor.id
client_id = each.key
name = each.key
enabled = true
access_type = "CONFIDENTIAL"
standard_flow_enabled = true
direct_access_grants_enabled = false
valid_redirect_uris = each.value.redirect_uris
valid_post_logout_redirect_uris = each.value.post_logout_redirect_uris
web_origins = each.value.web_origins
}
resource "keycloak_openid_group_membership_protocol_mapper" "oauth2_app_groups" {
for_each = var.oauth2_applications
realm_id = keycloak_realm.hexor.id
client_id = keycloak_openid_client.oauth2_app[each.key].id
name = "groups"
claim_name = "groups"
full_path = false
}
resource "keycloak_openid_client_default_scopes" "oauth2_app" {
for_each = var.oauth2_applications
realm_id = keycloak_realm.hexor.id
client_id = keycloak_openid_client.oauth2_app[each.key].id
default_scopes = concat(
["openid", "profile", "email"],
each.value.extra_default_scopes
)
}
resource "keycloak_openid_client_optional_scopes" "oauth2_app" {
for_each = {
for k, v in var.oauth2_applications : k => v if length(v.extra_optional_scopes) > 0
}
realm_id = keycloak_realm.hexor.id
client_id = keycloak_openid_client.oauth2_app[each.key].id
optional_scopes = each.value.extra_optional_scopes
}
resource "keycloak_group" "oauth2_app" {
for_each = {
for k, v in var.oauth2_applications : k => v if length(v.allowed_groups) > 0
}
realm_id = keycloak_realm.hexor.id
name = "app-${each.key}"
}
# =============================================================================
# Proxy applications — routes ConfigMap
# =============================================================================
resource "kubernetes_config_map_v1" "auth_proxy_routes" {
metadata { metadata {
name = "auth-proxy-routes" name = "auth-proxy-routes"
namespace = "auth-proxy" namespace = "auth-proxy"
+9 -9
View File
@@ -15,15 +15,6 @@ output "rsauth2_proxy_client_secret" {
sensitive = true sensitive = true
} }
output "rsauth2_proxy_dev_client_id" {
value = keycloak_openid_client.rsauth2_proxy_dev.client_id
}
output "rsauth2_proxy_dev_client_secret" {
value = keycloak_openid_client.rsauth2_proxy_dev.client_secret
sensitive = true
}
output "standalone_groups" { output "standalone_groups" {
value = [for g in keycloak_group.standalone : g.name] value = [for g in keycloak_group.standalone : g.name]
} }
@@ -35,3 +26,12 @@ output "app_groups" {
output "app_allowed_groups" { output "app_allowed_groups" {
value = local.app_allowed_groups value = local.app_allowed_groups
} }
output "oauth2_app_client_ids" {
value = { for k, c in keycloak_openid_client.oauth2_app : k => c.client_id }
}
output "oauth2_app_client_secrets" {
value = { for k, c in keycloak_openid_client.oauth2_app : k => c.client_secret }
sensitive = true
}
+1 -1
View File
@@ -19,5 +19,5 @@ provider "keycloak" {
} }
provider "kubernetes" { provider "kubernetes" {
config_path = var.kubeconfig_path config_path = "~/.kube/config"
} }
+32
View File
@@ -0,0 +1,32 @@
groups = [
"hexor-admin",
"hexor-guest",
"game-servers-managers",
"argocd-admins",
]
proxy_applications = {
secret-reader = {
domain = "secret-reader.hexor.cy"
allowed_groups = ["hexor-guest", "hexor-admin"]
}
pass = {
domain = "pass.hexor.cy"
allowed_groups = ["hexor-guest", "hexor-admin"]
}
}
oauth2_applications = {
gitea = {
redirect_uris = ["https://gt.hexor.cy/user/oauth2/Keycloak/callback"]
web_origins = ["https://gt.hexor.cy"]
post_logout_redirect_uris = ["https://gt.hexor.cy/*"]
}
ArgoCD = {
redirect_uris = ["https://ag.hexor.cy/auth/callback"]
web_origins = ["https://ag.hexor.cy"]
post_logout_redirect_uris = ["https://ag.hexor.cy/*"]
extra_optional_scopes = ["offline_access"]
}
}
+13 -6
View File
@@ -16,12 +16,6 @@ variable "keycloak_client_secret" {
sensitive = true sensitive = true
} }
variable "kubeconfig_path" {
description = "Path to kubeconfig (set via TF_VAR_kubeconfig_path or KUBE_CONFIG_PATH)"
type = string
default = "~/.kube/config"
}
variable "google_client_id" { variable "google_client_id" {
description = "Google OAuth client ID (set via TF_VAR_google_client_id)" description = "Google OAuth client ID (set via TF_VAR_google_client_id)"
type = string type = string
@@ -47,3 +41,16 @@ variable "proxy_applications" {
})) }))
default = {} default = {}
} }
variable "oauth2_applications" {
description = "OAuth2/OIDC applications that handle authentication themselves"
type = map(object({
redirect_uris = list(string)
post_logout_redirect_uris = optional(list(string), [])
web_origins = optional(list(string), [])
extra_default_scopes = optional(list(string), [])
extra_optional_scopes = optional(list(string), [])
allowed_groups = optional(list(string), [])
}))
default = {}
}