Refacto and add lb
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
locals {
|
||||
app_slug = "${var.instance}${var.component==""?"":"-"}${var.component}"
|
||||
oauth2_labels = merge(var.labels, {
|
||||
"app.kubernetes.io/component" = "authentik-oauth2"
|
||||
})
|
||||
}
|
||||
resource "kubectl_manifest" "oauth2-secret" {
|
||||
ignore_fields = ["metadata.annotations"]
|
||||
yaml_body = <<-EOF
|
||||
apiVersion: "secretgenerator.mittwald.de/v1alpha1"
|
||||
kind: "StringSecret"
|
||||
metadata:
|
||||
name: "${var.component}-${var.instance}-id"
|
||||
name: "${local.app_slug}-id"
|
||||
namespace: "${var.namespace}"
|
||||
labels: ${jsonencode(var.labels)}
|
||||
labels: ${jsonencode(local.oauth2_labels)}
|
||||
spec:
|
||||
forceRegenerate: false
|
||||
fields:
|
||||
@@ -19,6 +25,7 @@ data "kubernetes_secret_v1" "oauth2-client-id" {
|
||||
metadata {
|
||||
name = kubectl_manifest.oauth2-secret.name
|
||||
namespace = var.namespace
|
||||
labels = local.oauth2_labels
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +48,7 @@ data "authentik_flow" "default-authentication-flow" {
|
||||
}
|
||||
|
||||
resource "authentik_provider_oauth2" "oauth2" {
|
||||
name = "${var.component}-${var.instance}"
|
||||
name = "${local.app_slug}"
|
||||
client_id = data.kubernetes_secret_v1.oauth2-client-id.data["client-id"]
|
||||
authentication_flow = data.authentik_flow.default-authentication-flow.id
|
||||
authorization_flow = data.authentik_flow.default-authorization-flow.id
|
||||
@@ -56,9 +63,9 @@ resource "authentik_provider_oauth2" "oauth2" {
|
||||
|
||||
resource "kubernetes_secret_v1" "oauth2-client-secret" {
|
||||
metadata {
|
||||
name = "${var.component}-${var.instance}-secret"
|
||||
name = "${local.app_slug}-secret"
|
||||
namespace = var.namespace
|
||||
labels = var.labels
|
||||
labels = local.oauth2_labels
|
||||
}
|
||||
data = {
|
||||
client-secret = authentik_provider_oauth2.oauth2.client_secret
|
||||
|
||||
@@ -6,7 +6,7 @@ output "sso_signout_url" {
|
||||
value = "https://${data.kubernetes_ingress_v1.authentik.spec[0].rule[0].host}/application/o/${var.component}-${var.instance}/end-session/"
|
||||
}
|
||||
output "sso_configuration_url" {
|
||||
value = "https://${data.kubernetes_ingress_v1.authentik.spec[0].rule[0].host}/application/o/${var.component}-${var.instance}"
|
||||
value = "https://${data.kubernetes_ingress_v1.authentik.spec[0].rule[0].host}/application/o/${local.app_slug}/"
|
||||
}
|
||||
output "sso_userinfo_url" {
|
||||
value = "https://${data.kubernetes_ingress_v1.authentik.spec[0].rule[0].host}/application/o/userinfo/"
|
||||
|
||||
Reference in New Issue
Block a user