Added Authentik TF code
All checks were successful
Check with kubeconform / lint (push) Successful in 12s
All checks were successful
Check with kubeconform / lint (push) Successful in 12s
This commit is contained in:
@@ -11,6 +11,30 @@ terraform {
|
||||
}
|
||||
}
|
||||
|
||||
# Get all available scope mappings
|
||||
data "authentik_property_mapping_provider_scope" "all_scopes" {
|
||||
managed_list = [
|
||||
"goauthentik.io/providers/oauth2/scope-email",
|
||||
"goauthentik.io/providers/oauth2/scope-openid",
|
||||
"goauthentik.io/providers/oauth2/scope-profile"
|
||||
]
|
||||
}
|
||||
|
||||
# Filter scope mappings based on requested scopes
|
||||
locals {
|
||||
scope_name_mapping = {
|
||||
"openid" = "goauthentik.io/providers/oauth2/scope-openid"
|
||||
"profile" = "goauthentik.io/providers/oauth2/scope-profile"
|
||||
"email" = "goauthentik.io/providers/oauth2/scope-email"
|
||||
}
|
||||
|
||||
selected_scope_ids = [
|
||||
for scope in var.scope_mappings :
|
||||
data.authentik_property_mapping_provider_scope.all_scopes.ids[index(data.authentik_property_mapping_provider_scope.all_scopes.managed_list, local.scope_name_mapping[scope])]
|
||||
if contains(keys(local.scope_name_mapping), scope)
|
||||
]
|
||||
}
|
||||
|
||||
resource "random_password" "client_secret" {
|
||||
count = var.client_secret == null ? 1 : 0
|
||||
length = 40
|
||||
@@ -25,8 +49,19 @@ resource "authentik_provider_oauth2" "provider" {
|
||||
authorization_flow = var.authorization_flow
|
||||
invalidation_flow = var.invalidation_flow
|
||||
include_claims_in_id_token = var.include_claims_in_id_token
|
||||
access_code_validity = var.access_code_validity
|
||||
access_token_validity = var.access_token_validity
|
||||
refresh_token_validity = var.refresh_token_validity
|
||||
signing_key = var.signing_key
|
||||
|
||||
property_mappings = var.property_mappings
|
||||
allowed_redirect_uris = [
|
||||
for uri in var.redirect_uris : {
|
||||
matching_mode = "strict"
|
||||
url = uri
|
||||
}
|
||||
]
|
||||
|
||||
property_mappings = length(var.property_mappings) > 0 ? var.property_mappings : local.selected_scope_ids
|
||||
}
|
||||
|
||||
resource "random_id" "client_id" {
|
||||
@@ -56,4 +91,13 @@ resource "authentik_policy_binding" "app_access" {
|
||||
timeout = lookup(each.value, "timeout", 30)
|
||||
negate = lookup(each.value, "negate", false)
|
||||
failure_result = lookup(each.value, "failure_result", true)
|
||||
}
|
||||
|
||||
# Binding groups to the application
|
||||
resource "authentik_policy_binding" "group_bindings" {
|
||||
for_each = { for idx, group_id in var.access_groups : idx => group_id }
|
||||
|
||||
target = authentik_application.app.uuid
|
||||
group = each.value
|
||||
order = 10 + each.key
|
||||
}
|
||||
Reference in New Issue
Block a user