Refacto and add modules

This commit is contained in:
2024-02-06 11:03:20 +01:00
parent 140321f714
commit 1e1cedcaeb
47 changed files with 685 additions and 360 deletions

View File

@@ -1,3 +1,3 @@
output "provider-id" {
value = authentik_provider_saml.prj.id
}
value = authentik_provider_saml.prj.id
}

View File

@@ -1,12 +1,12 @@
terraform {
required_providers {
kubectl = {
source = "gavinbunney/kubectl"
version = "~> 1.14.0"
source = "gavinbunney/kubectl"
version = "~> 1.14.0"
}
authentik = {
source = "goauthentik/authentik"
version = "~> 2023.5.0"
source = "goauthentik/authentik"
version = "~> 2023.5.0"
}
}
}

View File

@@ -1,25 +1,25 @@
locals{
app_slug = "${var.instance}${var.component==""?"":"-"}${var.component}"
saml_labels = merge(var.labels, {
locals {
app_slug = "${var.instance}${var.component == "" ? "" : "-"}${var.component}"
saml_labels = merge(var.labels, {
"app.kubernetes.io/component" = "authentik-saml"
})
}
data "authentik_flow" "default-authorization-flow" {
data "authentik_flow" "default_authorization_flow" {
slug = "default-provider-authorization-implicit-consent"
}
data "authentik_flow" "default-authentication-flow" {
data "authentik_flow" "default_authentication_flow" {
slug = "default-authentication-flow"
}
data "authentik_property_mapping_saml" "saml_maps" {
managed_list = [
"goauthentik.io/providers/saml/email",
"goauthentik.io/providers/saml/groups",
"goauthentik.io/providers/saml/name",
"goauthentik.io/providers/saml/upn",
"goauthentik.io/providers/saml/uid",
"goauthentik.io/providers/saml/username",
"goauthentik.io/providers/saml/ms-windowsaccountname",
"goauthentik.io/providers/saml/email",
"goauthentik.io/providers/saml/groups",
"goauthentik.io/providers/saml/name",
"goauthentik.io/providers/saml/upn",
"goauthentik.io/providers/saml/uid",
"goauthentik.io/providers/saml/username",
"goauthentik.io/providers/saml/ms-windowsaccountname",
]
}
@@ -32,7 +32,7 @@ data "authentik_certificate_key_pair" "generated" {
}
resource "kubectl_manifest" "saml_certificate" {
yaml_body = <<-EOF
yaml_body = <<-EOF
apiVersion: "cert-manager.io/v1"
kind: "Certificate"
metadata:
@@ -51,8 +51,8 @@ resource "kubectl_manifest" "saml_certificate" {
resource "authentik_provider_saml" "prj" {
name = "${local.app_slug}-saml"
authentication_flow = data.authentik_flow.default-authentication-flow.id
authorization_flow = data.authentik_flow.default-authorization-flow.id
authentication_flow = data.authentik_flow.default_authentication_flow.id
authorization_flow = data.authentik_flow.default_authorization_flow.id
acs_url = "https://${var.dns_names[0]}/${var.acs_path}"
property_mappings = data.authentik_property_mapping_saml.saml_maps.ids
name_id_mapping = data.authentik_property_mapping_saml.saml_name.id

View File

@@ -1,22 +1,22 @@
variable "component" {
type = string
type = string
}
variable "instance" {
type = string
type = string
}
variable "issuer" {
type = string
}
variable "dns_names" {
type = list(string)
type = list(string)
}
variable "acs_path" {
type = string
type = string
}
variable "binding" {
type = string
default = "post"
type = string
default = "post"
}
variable "labels" {
type = map(string)
type = map(string)
}