71 lines
2.1 KiB
HCL
71 lines
2.1 KiB
HCL
data "authentik_flow" "default_authorization_flow" {
|
|
slug = "default-provider-authorization-implicit-consent"
|
|
}
|
|
data "authentik_flow" "default_invalidation_flow" {
|
|
slug = "default-provider-invalidation-flow"
|
|
}
|
|
|
|
|
|
data "authentik_certificate_key_pair" "ecdsa" {
|
|
name = "auth.serguzim.me"
|
|
}
|
|
|
|
data "authentik_certificate_key_pair" "rsa" {
|
|
name = "authentik Self-signed Certificate"
|
|
}
|
|
|
|
data "authentik_property_mapping_provider_scope" "default_scopes" {
|
|
managed_list = [
|
|
"goauthentik.io/providers/oauth2/scope-email",
|
|
"goauthentik.io/providers/oauth2/scope-openid",
|
|
"goauthentik.io/providers/oauth2/scope-profile"
|
|
]
|
|
}
|
|
|
|
resource "authentik_user" "default" {
|
|
username = "serguzim"
|
|
name = "Tobias Reisinger"
|
|
email = var.admin_email
|
|
}
|
|
|
|
resource "authentik_group" "grafana_grafana_admins" {
|
|
name = "Grafana GrafanaAdmins"
|
|
users = [authentik_user.default.id]
|
|
}
|
|
|
|
resource "authentik_group" "grafana_admins" {
|
|
name = "Grafana Admins"
|
|
}
|
|
|
|
resource "authentik_group" "grafana_editors" {
|
|
name = "Grafana Editors"
|
|
}
|
|
|
|
resource "authentik_group" "grafana_viewers" {
|
|
name = "Grafana Viewers"
|
|
}
|
|
|
|
|
|
resource "authentik_provider_oauth2" "service_providers" {
|
|
for_each = local.services_auth
|
|
name = each.key
|
|
client_type = "confidential"
|
|
client_id = each.key
|
|
authorization_flow = data.authentik_flow.default_authorization_flow.id
|
|
invalidation_flow = data.authentik_flow.default_invalidation_flow.id
|
|
allowed_redirect_uris = [for redir in each.value.auth_redirects : {
|
|
matching_mode = "strict",
|
|
url = redir,
|
|
}]
|
|
property_mappings = data.authentik_property_mapping_provider_scope.default_scopes.ids
|
|
signing_key = (each.value.auth_cert == "rsa" ?
|
|
data.authentik_certificate_key_pair.rsa.id :
|
|
data.authentik_certificate_key_pair.ecdsa.id)
|
|
}
|
|
|
|
resource "authentik_application" "service_applications" {
|
|
for_each = local.services_auth
|
|
name = each.key
|
|
slug = replace(each.value.dns[0].domain, ".", "-")
|
|
protocol_provider = authentik_provider_oauth2.service_providers[each.key].id
|
|
}
|