Fix authentik config

This commit is contained in:
Tobias Reisinger 2024-10-09 02:29:08 +02:00
parent 979a386831
commit 424e1db07f
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
9 changed files with 17 additions and 7 deletions

View file

@ -88,6 +88,7 @@ variable "services" {
}))) })))
ports = optional(list(string)) ports = optional(list(string))
auth = bool auth = bool
auth_cert = optional(string)
auth_redirects = optional(list(string)) auth_redirects = optional(list(string))
s3 = bool s3 = bool
database = bool database = bool

View file

@ -2,10 +2,14 @@ data "authentik_flow" "default_authorization_flow" {
slug = "default-provider-authorization-implicit-consent" slug = "default-provider-authorization-implicit-consent"
} }
data "authentik_certificate_key_pair" "default" { data "authentik_certificate_key_pair" "ecdsa" {
name = "auth.serguzim.me" name = "auth.serguzim.me"
} }
data "authentik_certificate_key_pair" "rsa" {
name = "authentik Self-signed Certificate"
}
data "authentik_property_mapping_provider_scope" "default_scopes" { data "authentik_property_mapping_provider_scope" "default_scopes" {
managed_list = [ managed_list = [
"goauthentik.io/providers/oauth2/scope-email", "goauthentik.io/providers/oauth2/scope-email",
@ -58,7 +62,9 @@ resource "authentik_provider_oauth2" "service_providers" {
data.authentik_property_mapping_provider_scope.default_scopes.ids, data.authentik_property_mapping_provider_scope.default_scopes.ids,
each.key == "minio" ? [authentik_property_mapping_provider_scope.minio.id] : [] each.key == "minio" ? [authentik_property_mapping_provider_scope.minio.id] : []
]) ])
signing_key = data.authentik_certificate_key_pair.default.id 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" { resource "authentik_application" "service_applications" {

View file

@ -1,7 +1,7 @@
output "authentik_data" { output "authentik_data" {
value = { value = {
for key in keys(authentik_application.service_applications) : key => { for key in keys(authentik_application.service_applications) : key => {
"base_url" = "${var.authentik_url}/application/o/${authentik_application.service_applications[key].slug}/" "base_url" = "${var.authentik_url}/application/o/${authentik_application.service_applications[key].slug}"
"client_id" = authentik_provider_oauth2.service_providers[key].client_id "client_id" = authentik_provider_oauth2.service_providers[key].client_id
"client_secret" = authentik_provider_oauth2.service_providers[key].client_secret "client_secret" = authentik_provider_oauth2.service_providers[key].client_secret
} }

View file

@ -37,6 +37,7 @@ variable "services" {
}))) })))
ports = optional(list(string)) ports = optional(list(string))
auth = bool auth = bool
auth_cert = optional(string)
auth_redirects = optional(list(string)) auth_redirects = optional(list(string))
s3 = bool s3 = bool
database = bool database = bool

View file

@ -47,7 +47,7 @@ gatus_yml:
security: security:
oidc: oidc:
issuer-url: "{{ opentofu.authentik_data.gatus.base_url }}" issuer-url: "{{ opentofu.authentik_data.gatus.base_url }}/"
redirect-url: "https://{{ gatus_svc.domain }}/authorization-code/callback" redirect-url: "https://{{ gatus_svc.domain }}/authorization-code/callback"
client-id: "{{ opentofu.authentik_data.gatus.client_id }}" client-id: "{{ opentofu.authentik_data.gatus.client_id }}"
client-secret: "{{ opentofu.authentik_data.gatus.client_secret }}" client-secret: "{{ opentofu.authentik_data.gatus.client_secret }}"

View file

@ -27,8 +27,8 @@ linkwarden_env:
SPACES_FORCE_PATH_STYLE: false SPACES_FORCE_PATH_STYLE: false
NEXT_PUBLIC_DISABLE_REGISTRATION: true NEXT_PUBLIC_DISABLE_REGISTRATION: true
NEXT_PUBLIC_CREDENTIALS_ENABLED: true NEXT_PUBLIC_CREDENTIALS_ENABLED: false
NEXT_PUBLIC_AUTHENTIK_ENABLED: false NEXT_PUBLIC_AUTHENTIK_ENABLED: true
AUTHENTIK_CUSTOM_NAME: auth.serguzim.me AUTHENTIK_CUSTOM_NAME: auth.serguzim.me
AUTHENTIK_ISSUER: "{{ opentofu.authentik_data.linkwarden.base_url }}" AUTHENTIK_ISSUER: "{{ opentofu.authentik_data.linkwarden.base_url }}"
AUTHENTIK_CLIENT_ID: "{{ opentofu.authentik_data.linkwarden.client_id }}" AUTHENTIK_CLIENT_ID: "{{ opentofu.authentik_data.linkwarden.client_id }}"

View file

@ -40,7 +40,7 @@ vikunja_yml:
enabled: true enabled: true
providers: providers:
- name: auth.serguzim.me - name: auth.serguzim.me
authurl: "{{ opentofu.authentik_data.vikunja.base_url }}" authurl: "{{ opentofu.authentik_data.vikunja.base_url }}/"
logouturl: "{{ (opentofu.authentik_data.vikunja.base_url, 'end-session') | path_join }}" logouturl: "{{ (opentofu.authentik_data.vikunja.base_url, 'end-session') | path_join }}"
clientid: "{{ opentofu.authentik_data.vikunja.client_id }}" clientid: "{{ opentofu.authentik_data.vikunja.client_id }}"
clientsecret: "{{ opentofu.authentik_data.vikunja.client_secret }}" clientsecret: "{{ opentofu.authentik_data.vikunja.client_secret }}"

View file

@ -233,6 +233,7 @@ services = {
group = "4-services" group = "4-services"
} }
auth = true auth = true
auth_cert = "rsa"
auth_redirects = ["https://bookmarks.serguzim.me/api/v1/auth/callback/authentik"] auth_redirects = ["https://bookmarks.serguzim.me/api/v1/auth/callback/authentik"]
database = true database = true
s3 = true s3 = true

View file

@ -144,6 +144,7 @@ variable "services" {
})) }))
ports = optional(list(string)) ports = optional(list(string))
auth = bool auth = bool
auth_cert = optional(string)
auth_redirects = optional(list(string)) auth_redirects = optional(list(string))
s3 = bool s3 = bool
database = bool database = bool