diff --git a/.forgejo/workflows/authentik.yaml b/.forgejo/workflows/authentik.yaml index 72b7793..0090290 100644 --- a/.forgejo/workflows/authentik.yaml +++ b/.forgejo/workflows/authentik.yaml @@ -2,6 +2,8 @@ on: push: branches: - 'main' + path: + - '**/authentik' jobs: authentik": diff --git a/10-pre-k8s/.terraform.lock.hcl b/10-pre-k8s/.terraform.lock.hcl index 2d9018f..1139ded 100644 --- a/10-pre-k8s/.terraform.lock.hcl +++ b/10-pre-k8s/.terraform.lock.hcl @@ -1,11 +1,11 @@ -# This file is maintained automatically by "terraform init". +# This file is maintained automatically by "tofu init". # Manual edits may be lost in future updates. -provider "registry.terraform.io/backblaze/b2" { +provider "registry.opentofu.org/backblaze/b2" { version = "0.8.6" constraints = "0.8.6" hashes = [ - "h1:FUV3MlKORho03jB7xK4RHLqIoesXEpwDY3Q7j2niEtU=", + "h1:d1N+yXGYMvMlubgZMAtiN7UycJbd0IzEYkn/3iJuikU=", "zh:301cb0e9ad3f094e6cb182ffd1496234273d3e9138d03cbf234baf4edabaf0fb", "zh:3b39c96c0b3081c5d9f372a355527835d26792ffaf6dc06fb390d2c76d09c394", "zh:736a6d688bb261a3154970f7b487e142e02b02d1e4d877cce763539f4222cc8d", @@ -13,11 +13,11 @@ provider "registry.terraform.io/backblaze/b2" { ] } -provider "registry.terraform.io/community-terraform-providers/ignition" { +provider "registry.opentofu.org/community-terraform-providers/ignition" { version = "2.2.2" constraints = "2.2.2" hashes = [ - "h1:wyXgqs6swQUQ6Dow13ea1nmGRix+lXxPVP3s7qwnrO4=", + "h1:9Ik7Bt3+ZXR9WTmYJoy1cc4lHW2k4BqcWja3Le/Hey0=", "zh:1c40157dfa3b035f4298f5f84dd0f4f9cfc321a19bc674620ee8f80f416ebd8c", "zh:318435a26c18e32992e40ae91752256043bffb53fbfdc796d33fa03e0ad52784", "zh:3535ce2f2dce787b37e76a49d1c8554f0fcf1a43041f1343a1314749b11136d0", @@ -33,11 +33,11 @@ provider "registry.terraform.io/community-terraform-providers/ignition" { ] } -provider "registry.terraform.io/ivoronin/macaddress" { +provider "registry.opentofu.org/ivoronin/macaddress" { version = "0.3.2" constraints = "0.3.2" hashes = [ - "h1:jJ/LOHNgy5hDoVfE+Si4YoRQ0jpCGAAZFMF21lGE0nw=", + "h1:yk0ASl2cAoc/22tvpi9Kke+WvowgXGq0QwaP93IQ+S0=", "zh:00cb168d9210ed88cfa7de8a33d5666b2cf6660a5d20a7a96348b8b902833eca", "zh:1366458320df0b6f1132e59b5410931c0c5626bbf27b05b29dd311311a710e9b", "zh:2e8102c7f6046665c95b806752d692843f2e846554f7eba85690cd2087c9048a", @@ -55,11 +55,11 @@ provider "registry.terraform.io/ivoronin/macaddress" { ] } -provider "registry.terraform.io/poseidon/matchbox" { +provider "registry.opentofu.org/poseidon/matchbox" { version = "0.5.2" constraints = "0.5.2" hashes = [ - "h1:ZlO7fr0TYs0Gyfl5xx3fcVSlzcaorr1QWOYbTebSqO8=", + "h1:Ruxh/CtMiqESV+j+aivpaT2/UM0M3CF6oKXbuq2PfLk=", "zh:2f51a49a5418cf22dc7201c22d0bd1ff7fc095eb97688f040491492e319fe076", "zh:44db04a6867a1116a7a41919d94abf9d2725bc87130d8ee5f9055457639d1e94", "zh:4e59679bcde22a111b45371e86941562ccdd7db3895762eb2f512419f9d6653d", @@ -68,11 +68,11 @@ provider "registry.terraform.io/poseidon/matchbox" { ] } -provider "registry.terraform.io/siderolabs/talos" { +provider "registry.opentofu.org/siderolabs/talos" { version = "0.4.0-alpha.0" constraints = "0.4.0-alpha.0" hashes = [ - "h1:04PT2Q9ubBLFCXqMEahR9M3mPYjDfe9Tn05QaUNi6qs=", + "h1:LygqCd18h7jYuQAR6CzajEN9lhA4gPQn7SKHcxVhSxc=", "zh:0f7561370fe15a33b7ded55fe27a21f6e45b2a4950502edfcdb583fd91771239", "zh:0fa82a384b25a58b65523e0ea4768fa1212b1f5cfc0c9379d31162454fedcc9d", "zh:1bdbf5927dd4e810f14e159fe0e5f4873b7144a58e5aee5d95e2e33b03280152", @@ -91,11 +91,11 @@ provider "registry.terraform.io/siderolabs/talos" { ] } -provider "registry.terraform.io/tailscale/tailscale" { +provider "registry.opentofu.org/tailscale/tailscale" { version = "0.13.11" constraints = "0.13.11" hashes = [ - "h1:4trmz0fx3JthZewl82y3UzzMzGaTgpjdP7+MNsq5H0k=", + "h1:VzdUBi2ssTjRODk4BZ0qNR1G92mv0P2irNp69CqHN1Q=", "zh:0ad8afd43061faadd0f72c03bad81d900fd43ed0051318e6312e2a29f34064e0", "zh:19e74391245935ba0d37f03db66d913194e99233118df95323555277defb6aaf", "zh:35e956483901dcb97672c3200d7326f0913b3ce981d33ed89ee2fe3622a4347c", diff --git a/20-post-k8s/.terraform.lock.hcl b/20-post-k8s/.terraform.lock.hcl index c1f449c..b066032 100644 --- a/20-post-k8s/.terraform.lock.hcl +++ b/20-post-k8s/.terraform.lock.hcl @@ -2,31 +2,29 @@ # Manual edits may be lost in future updates. provider "registry.opentofu.org/backblaze/b2" { - version = "0.8.6" - constraints = "0.8.6" + version = "0.8.12" hashes = [ - "h1:FUV3MlKORho03jB7xK4RHLqIoesXEpwDY3Q7j2niEtU=", - "zh:301cb0e9ad3f094e6cb182ffd1496234273d3e9138d03cbf234baf4edabaf0fb", - "zh:3b39c96c0b3081c5d9f372a355527835d26792ffaf6dc06fb390d2c76d09c394", - "zh:736a6d688bb261a3154970f7b487e142e02b02d1e4d877cce763539f4222cc8d", - "zh:ba26881679d2ce35b5f35f75309f5d480060fb29d655fd0e201dbbd55aabd345", + "h1:rA+Y9HyJGPV7kU52+9vKRM90RiGjdwj9Tas5ZImfsw0=", + "zh:bc9d25d21adeafba8edde8d6ffb6150cd5c86c207412c8941347966be3363de5", + "zh:c538eaea1b15379635b9d8a2cb862248813022bb0de5481741f18fcc77a10a1b", + "zh:cc2767797ad27b9a3b4ad97b6a2f3eeea9f50a6000bbcfa9b44189945dae30b3", + "zh:d83b5f0e632ea56570a0737c1896f049367201cc67f5de83baa24272ccdd56a4", ] } provider "registry.opentofu.org/hashicorp/kubernetes" { - version = "2.31.0" - constraints = "2.31.0" + version = "2.32.0" hashes = [ - "h1:MfkGdRph9sDol+ukIgIigdXuLLpC2JPUHH5oF2zEfTM=", - "zh:0dd25babf78a88a61dd329b8c18538a295ea63630f1b69575e7898c89307da39", - "zh:3138753e4b2ce6e9ffa5d65d73e9236169ff077c10089c7dc71031a0a139ff6d", - "zh:644f94692dc33de0bb1183c307ae373efbf4ef4cb92654ccc646a5716edf9593", - "zh:6cc630e43193220b1599e3227286cc4e3ca195910e8c56b6bacb50c5b5176dbf", - "zh:764173875e77aa482da4dca9fec5f77c455d028848edfc394aa7dac5dfed6afd", - "zh:7b1d380362d50ffbb3697483036ae351b0571e93b33754255cde6968e62b839f", - "zh:a1d93ca3d8d1ecdd3b69242d16ff21c91b34e2e98f02a3b2d02c908aeb45189b", - "zh:b471d0ab56dbf19c95fba68d2ef127bdb353be96a2be4c4a3dcd4d0db4b4180a", - "zh:d610f725ded4acd3d31a240472bb283aa5e657ed020395bdefea18d094b8c2bf", - "zh:d7f3ddd636ad5af6049922f212feb24830b7158410819c32073bf81c359cd2fa", + "h1:ZRCFOIecOlTIrpf1O/kmbFfBMQe9r8/HwiiK9kP0KEk=", + "zh:06d586c8fcd3ab8fe7f3ac99142ba48b9efbff8bebe05c52b3c7997f83146200", + "zh:12ce862493717118a6bf68328448d09023a60344da25633e124423cdd734263e", + "zh:33ee1cda5db58fd26576ba6be715282af30e04d25b38fd6752810fd206bc6422", + "zh:8f4e13c726a5fb84244eff7740b20678e7fb2d5df6ebc759101d4c58fb069112", + "zh:8fe15d350b5a018f535a93fa054bf4d05377a69f3b1e5cabe8c73d059a4b70cb", + "zh:953fc8c8a92ff0defafd22ee0aec12d483d7b80685de6838e513d4de7170a651", + "zh:a1ad6197105f9cda73c39f3b69dd688ec22708c736de05c03516561a88f4bbfc", + "zh:c1d60898c269f42ece0b3672901001ba26338c865f83a39b116c0d6c0cd8dbc1", + "zh:d26fcff2fda9421d9129fd407696481ecd2714ae3316e81ff977e2e40de068e5", + "zh:dc616b73095755245f211af0989bfcf2f76b43196bf7f8982183e4e3b1c3f6f6", ] } diff --git a/20-post-k8s/loki.tf b/20-post-k8s/loki.tf index 13441e3..c73ecfb 100644 --- a/20-post-k8s/loki.tf +++ b/20-post-k8s/loki.tf @@ -1,5 +1,5 @@ -resource "b2_bucket" "cowley-tech-home-backup" { - bucket_name = "cowley-tech-k3s-logs" +resource "b2_bucket" "cowley-tech-home-logs" { + bucket_name = "cowley-tech-home-logs" bucket_type = "allPrivate" } diff --git a/20-post-k8s/provider.tf b/20-post-k8s/provider.tf index b1821fd..55554a2 100644 --- a/20-post-k8s/provider.tf +++ b/20-post-k8s/provider.tf @@ -7,11 +7,11 @@ terraform { required_providers { b2 = { source = "Backblaze/b2" - version = "0.8.6" + #version = "0.8.6" } kubernetes = { source = "hashicorp/kubernetes" - version = "2.31.0" + #version = "2.31.0" } } } diff --git a/authentik.old/.terraform.lock.hcl b/authentik.old/.terraform.lock.hcl new file mode 100644 index 0000000..b72c3c5 --- /dev/null +++ b/authentik.old/.terraform.lock.hcl @@ -0,0 +1,77 @@ +# This file is maintained automatically by "tofu init". +# Manual edits may be lost in future updates. + +provider "registry.opentofu.org/goauthentik/authentik" { + version = "2024.10.2" + constraints = "2024.10.2" + hashes = [ + "h1:qjDOLb8+12kZHSM3VsItQCsZYJhDMD4bNKSZi15HQ28=", + "zh:06c6c9bb2716052fefc1013ed1a77a12159d5625fe43857700c282e80e2fbba1", + "zh:121e45b3d3675df24e2c1bb107e2ed15fc9f1ec8b602b9bdaebec71481addf0c", + "zh:2aec74c8df3e3eb56fb09edcb1c7f43c91f932b2ef2327aa855ba0819f11169e", + "zh:4f2bf009f43293a24cc8941d4bbab340a53f569a9331aa615a7934f500a64290", + "zh:64b150655b47c60e6ae72a2ee754f5019b2baabd4dc292a6b2b960b3a206e218", + "zh:78bf3fd7cbac489d23a620743e5af5b85b31fc548433cf86f0861878b68f2666", + "zh:7ce7a02671056d476d17652d780ee2bd309ce34eb77746719b7b277ca66b7c58", + "zh:84fdb911186918cbba86c1390ce18a4423f0d748216f2d9c8421801b34b41f16", + "zh:95db38fb110302707cd70471f5cb2bf361ed6d5987f7b6fe5f3c5855f9dc9b64", + "zh:9c24dbf6512637bb1d4201a901dddef0210b440ad8b02717ca1167b75afa6882", + "zh:a83bc8bfe87e44c788c3c974e764c7bfb1c5fb982f427a5b928c50e55b48dea6", + "zh:b5a4d5d1f2f0e8d65ad29a23bfd72d0d4e3e06e9bacea9463a10e67137833409", + "zh:d1e08a662ab7c80373bc13446c9b316a671fcddec6aeffef7ab3649d1bbfb76b", + "zh:e1c50a791f2d53f7b464ab122f92062547d5a4ad71297f5e7f0375453cd2034f", + ] +} + +provider "registry.opentofu.org/hashicorp/kubernetes" { + version = "2.31.0" + constraints = "2.31.0" + hashes = [ + "h1:MfkGdRph9sDol+ukIgIigdXuLLpC2JPUHH5oF2zEfTM=", + "h1:z2qlqn6WbrjbezwQo4vvlwAgVUGz59klzDU4rlYhYi8=", + "zh:0dd25babf78a88a61dd329b8c18538a295ea63630f1b69575e7898c89307da39", + "zh:3138753e4b2ce6e9ffa5d65d73e9236169ff077c10089c7dc71031a0a139ff6d", + "zh:644f94692dc33de0bb1183c307ae373efbf4ef4cb92654ccc646a5716edf9593", + "zh:6cc630e43193220b1599e3227286cc4e3ca195910e8c56b6bacb50c5b5176dbf", + "zh:764173875e77aa482da4dca9fec5f77c455d028848edfc394aa7dac5dfed6afd", + "zh:7b1d380362d50ffbb3697483036ae351b0571e93b33754255cde6968e62b839f", + "zh:a1d93ca3d8d1ecdd3b69242d16ff21c91b34e2e98f02a3b2d02c908aeb45189b", + "zh:b471d0ab56dbf19c95fba68d2ef127bdb353be96a2be4c4a3dcd4d0db4b4180a", + "zh:d610f725ded4acd3d31a240472bb283aa5e657ed020395bdefea18d094b8c2bf", + "zh:d7f3ddd636ad5af6049922f212feb24830b7158410819c32073bf81c359cd2fa", + ] +} + +provider "registry.opentofu.org/hashicorp/local" { + version = "2.5.2" + hashes = [ + "h1:6lS+5A/4WFAqY3/RHWFRBSiFVLPRjvLaUgxPQvjXLHU=", + "zh:25b95b76ceaa62b5c95f6de2fa6e6242edbf51e7fc6c057b7f7101aa4081f64f", + "zh:3c974fdf6b42ca6f93309cf50951f345bfc5726ec6013b8832bcd3be0eb3429e", + "zh:5de843bf6d903f5cca97ce1061e2e06b6441985c68d013eabd738a9e4b828278", + "zh:86beead37c7b4f149a54d2ae633c99ff92159c748acea93ff0f3603d6b4c9f4f", + "zh:8e52e81d3dc50c3f79305d257da7fde7af634fed65e6ab5b8e214166784a720e", + "zh:9882f444c087c69559873b2d72eec406a40ede21acb5ac334d6563bf3a2387df", + "zh:a4484193d110da4a06c7bffc44cc6b61d3b5e881cd51df2a83fdda1a36ea25d2", + "zh:a53342426d173e29d8ee3106cb68abecdf4be301a3f6589e4e8d42015befa7da", + "zh:d25ef2aef6a9004363fc6db80305d30673fc1f7dd0b980d41d863b12dacd382a", + "zh:fa2d522fb323e2121f65b79709fd596514b293d816a1d969af8f72d108888e4c", + ] +} + +provider "registry.opentofu.org/hashicorp/random" { + version = "3.6.3" + hashes = [ + "h1:Ry0Lr0zaoicslZlcUR4rAySPpl/a7QupfMfuAxhW3fw=", + "zh:1bfd2e54b4eee8c761a40b6d99d45880b3a71abc18a9a7a5319204da9c8363b2", + "zh:21a15ac74adb8ba499aab989a4248321b51946e5431219b56fc827e565776714", + "zh:221acfac3f7a5bcd6cb49f79a1fca99da7679bde01017334bad1f951a12d85ba", + "zh:3026fcdc0c1258e32ab519df878579160b1050b141d6f7883b39438244e08954", + "zh:50d07a7066ea46873b289548000229556908c3be746059969ab0d694e053ee4c", + "zh:54280cdac041f2c2986a585f62e102bc59ef412cad5f4ebf7387c2b3a357f6c0", + "zh:632adf40f1f63b0c5707182853c10ae23124c00869ffff05f310aef2ed26fcf3", + "zh:b8c2876cce9a38501d14880a47e59a5182ee98732ad7e576e9a9ce686a46d8f5", + "zh:f27e6995e1e9fe3914a2654791fc8d67cdce44f17bf06e614ead7dfd2b13d3ae", + "zh:f423f2b7e5c814799ad7580b5c8ae23359d8d342264902f821c357ff2b3c6d3d", + ] +} diff --git a/authentik.old/Makefile b/authentik.old/Makefile new file mode 100644 index 0000000..9d23b4e --- /dev/null +++ b/authentik.old/Makefile @@ -0,0 +1,8 @@ +init: + @tofu init + +plan: + @tofu plan -out tfplan + +apply:plan + @tofu apply tfplan diff --git a/authentik.old/books.tf b/authentik.old/books.tf new file mode 100644 index 0000000..0a768b7 --- /dev/null +++ b/authentik.old/books.tf @@ -0,0 +1,48 @@ +resource "random_id" "books_client_id" { + + byte_length = 16 +} + +resource "authentik_provider_oauth2" "books" { + name = "AudioBookShelf" + # Required. You can use the output of: + # $ openssl rand -hex 16 + client_id = random_id.books_client_id.id + authentication_flow = data.authentik_flow.default-authentication-flow.id + authorization_flow = data.authentik_flow.default-provider-authorization-implicit-consent.id + invalidation_flow = data.authentik_flow.default-invalidation-flow.id + + client_type = "public" + + allowed_redirect_uris = [ + { + url = "https://books.lab.cowley.tech/", + matched_mode = "strict" + }, + { + matched_mode = "regex", + url = ".*" + } + ] + + sub_mode = "user_email" + + property_mappings = [ + data.authentik_property_mapping_provider_scope.scope-email.id, + data.authentik_property_mapping_provider_scope.scope-profile.id, + data.authentik_property_mapping_provider_scope.scope-openid.id, + ] + lifecycle { + ignore_changes = [ + signing_key, + authentication_flow, + ] + } +} + +resource "authentik_application" "books" { + name = "AudioBookShelf" + slug = "audiobookshelf" + protocol_provider = authentik_provider_oauth2.books.id + open_in_new_tab = true +} diff --git a/authentik.old/chat.tf b/authentik.old/chat.tf new file mode 100644 index 0000000..087ee52 --- /dev/null +++ b/authentik.old/chat.tf @@ -0,0 +1,58 @@ +resource "random_id" "chat_client_id" { + byte_length = 16 +} + +resource "authentik_provider_oauth2" "chat" { + name = "Chat" + # Required. You can use the output of: + # $ openssl rand -hex 16 + client_id = random_id.chat_client_id.id + + # Optional: will be generated if not provided + # client_secret = "my_client_secret" + + authorization_flow = data.authentik_flow.default-provider-authorization-implicit-consent.id + invalidation_flow = data.authentik_flow.default-invalidation-flow.id + + allowed_redirect_uris = [ + { + matched_mode = "strict", + url = "https://chat.lab.cowley.tech/oauth/oidc/callback", + }, + { + matched_mode = "regex", + url = ".*" + } + ] + property_mappings = [ + data.authentik_property_mapping_provider_scope.scope-openid.id, + data.authentik_property_mapping_provider_scope.scope-email.id, + data.authentik_property_mapping_provider_scope.scope-profile.id, + ] + lifecycle { + ignore_changes = [ + signing_key, + authentication_flow, + ] + } +} + +resource "authentik_application" "chat" { + name = "Chat" + slug = "chat" + protocol_provider = authentik_provider_oauth2.chat.id +} + +resource "kubernetes_secret" "chat" { + metadata { + name = "open-webui-authentik" + namespace = "ollama" + } + data = { + OAUTH_CLIENT_ID = authentik_provider_oauth2.chat.client_id + OAUTH_CLIENT_SECRET = authentik_provider_oauth2.chat.client_secret + OPENID_PROVIDER_URL = "https://auth.lab.cowley.tech/application/o/chat/.well-known/openid-configuration" + OAUTH_PROVIDER_NAME = "Authentik" + OAUTH_SCOPES = "openid email profile" + } +} diff --git a/authentik/dashy.tf b/authentik.old/dashy.tf similarity index 65% rename from authentik/dashy.tf rename to authentik.old/dashy.tf index c623c25..31b69d1 100644 --- a/authentik/dashy.tf +++ b/authentik.old/dashy.tf @@ -6,15 +6,22 @@ resource "authentik_provider_oauth2" "dashy" { name = "Dashy" # Required. You can use the output of: # $ openssl rand -hex 16 - client_id = random_id.dashy_client_id.id + client_id = random_id.dashy_client_id.id authentication_flow = data.authentik_flow.default-authentication-flow.id - authorization_flow = data.authentik_flow.default-provider-authorization-implicit-consent.id + authorization_flow = data.authentik_flow.default-provider-authorization-implicit-consent.id + invalidation_flow = data.authentik_flow.default-invalidation-flow.id client_type = "public" - redirect_uris = [ - "https://dash.lab.cowley.tech/", - ".*" + allowed_redirect_uris = [ + { + matched_mode = "strict", + url = "https://dash.lab.cowley.tech/", + }, + { + matched_mode = "regex", + url = ".*" + } ] sub_mode = "user_email" @@ -36,5 +43,5 @@ resource "authentik_application" "dashy" { name = "Dashy" slug = "dashy" protocol_provider = authentik_provider_oauth2.dashy.id - open_in_new_tab = true + open_in_new_tab = true } diff --git a/authentik.old/data.tf b/authentik.old/data.tf new file mode 100644 index 0000000..772f054 --- /dev/null +++ b/authentik.old/data.tf @@ -0,0 +1,21 @@ +data "authentik_flow" "default-provider-authorization-implicit-consent" { + slug = "default-provider-authorization-implicit-consent" +} + +data "authentik_flow" "default-authentication-flow" { + slug = "default-authentication-flow" +} +data "authentik_flow" "default-invalidation-flow" { + slug = "default-invalidation-flow" +} +data "authentik_property_mapping_provider_scope" "scope-email" { + name = "authentik default OAuth Mapping: OpenID 'email'" +} + +data "authentik_property_mapping_provider_scope" "scope-profile" { + name = "authentik default OAuth Mapping: OpenID 'profile'" +} + +data "authentik_property_mapping_provider_scope" "scope-openid" { + name = "authentik default OAuth Mapping: OpenID 'openid'" +} diff --git a/authentik.old/docs.tf b/authentik.old/docs.tf new file mode 100644 index 0000000..f01634d --- /dev/null +++ b/authentik.old/docs.tf @@ -0,0 +1,28 @@ +#resource "authentik_provider_proxy" "docs" { +# name = "docs" +# authorization_flow = data.authentik_flow.default-provider-authorization-implicit-consent.id +# external_host = "https://docs.lab.cowley.tech" +# internal_host = "http://homelab-docs.docs.svc.cluster.local" +#} +#resource "authentik_application" "docs" { +# name = "Homelab Docs" +# slug = "homelab-docs" +# protocol_provider = authentik_provider_proxy.docs.id +# meta_launch_url = "https://docs.lab.cowley.tech" +#} +#resource "authentik_outpost" "docs" { +# name = "docs" +# protocol_providers = [ +# authentik_provider_proxy.docs.id +# ] +# config = jsonencode({ +# "kubernetes_namespace": "docs", +# "kubernetes_ingress_class_name": "nginx", +# }) +# service_connection = authentik_service_connection_kubernetes.local.id +#} +# +#resource "authentik_service_connection_kubernetes" "local" { +# name = "local" +# local = true +#} diff --git a/authentik/foo.bar b/authentik.old/foo.bar similarity index 100% rename from authentik/foo.bar rename to authentik.old/foo.bar diff --git a/authentik/forgejo.tf b/authentik.old/forgejo.tf similarity index 77% rename from authentik/forgejo.tf rename to authentik.old/forgejo.tf index 07eff5d..7e0ad26 100644 --- a/authentik/forgejo.tf +++ b/authentik.old/forgejo.tf @@ -12,9 +12,13 @@ resource "authentik_provider_oauth2" "forgejo" { # client_secret = "my_client_secret" authorization_flow = data.authentik_flow.default-provider-authorization-implicit-consent.id + invalidation_flow = data.authentik_flow.default-invalidation-flow.id - redirect_uris = [ - "https://code.lab.cowley.tech/user/oauth2/authentik/callback" + allowed_redirect_uris = [ + { + matched_mode = "strict" + url = "https://code.lab.cowley.tech/user/oauth2/authentik/callback" + } ] property_mappings = [ data.authentik_property_mapping_provider_scope.scope-email.id, @@ -47,7 +51,7 @@ resource "kubernetes_secret" "forgejo-oauth" { namespace = "forgejo" } data = { - "key" = authentik_provider_oauth2.forgejo.client_id - "secret" = authentik_provider_oauth2.forgejo.client_secret + "key" = authentik_provider_oauth2.forgejo.client_id + "secret" = authentik_provider_oauth2.forgejo.client_secret } } diff --git a/authentik.old/grafana.tf b/authentik.old/grafana.tf new file mode 100644 index 0000000..97d85f9 --- /dev/null +++ b/authentik.old/grafana.tf @@ -0,0 +1,80 @@ + +resource "random_id" "client_id" { + byte_length = 16 +} + +resource "authentik_provider_oauth2" "grafana" { + name = "Grafana" + # Required. You can use the output of: + # $ openssl rand -hex 16 + client_id = random_id.client_id.id + + # Optional: will be generated if not provided + # client_secret = "my_client_secret" + + authorization_flow = data.authentik_flow.default-provider-authorization-implicit-consent.id + invalidation_flow = data.authentik_flow.default-invalidation-flow.id + + allowed_redirect_uris = [ + { + matched_mode = "strict", + url = "https://grafana.lab.cowley.tech/login/generic_oauth" + }, + ] + + property_mappings = [ + data.authentik_property_mapping_provider_scope.scope-email.id, + data.authentik_property_mapping_provider_scope.scope-profile.id, + data.authentik_property_mapping_provider_scope.scope-openid.id, + ] + + lifecycle { + ignore_changes = [ + signing_key, + authentication_flow, + ] + } +} + +resource "authentik_application" "grafana" { + name = "Grafana" + slug = "grafana" + protocol_provider = authentik_provider_oauth2.grafana.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 "kubernetes_secret" "grafana-authentik" { + metadata { + name = "grafana-authentik" + namespace = "monitoring" + } + data = { + "GF_AUTH_GENERIC_OAUTH_ENABLED" = "true" + "GF_AUTH_GENERIC_OAUTH_CLIENT_ID" = authentik_provider_oauth2.grafana.client_id + "GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET" = authentik_provider_oauth2.grafana.client_secret + "GF_AUTH_GENERIC_OAUTH_NAME" = "authentik" + "GF_AUTH_GENERIC_OAUTH_SCOPES" = "openid profile email" + "GF_AUTH_GENERIC_OAUTH_ALLOW_SIGN_UP" = "true" + "GF_AUTH_GENERIC_OAUTH_AUTH_URL" = "https://auth.lab.cowley.tech/application/o/authorize/" + "GF_AUTH_GENERIC_OAUTH_TOKEN_URL" = "https://auth.lab.cowley.tech/application/o/token/" + "GF_AUTH_GENERIC_OAUTH_API_URL" = "https://auth.lab.cowley.tech/application/o/userinfo/" + "GF_AUTH_SIGNOUT_REDIRECT_URL" = "https://auth.lab.cowley.tech/application/o/grafana/end-session/" + "GF_AUTH_GENERIC_SIGNOUT_REDIRECT_URL" = "https://auth.lab.cowley.tech/application/o/grafana/end-session/" + # Optionally enable auto-login (bypasses Grafana login screen) + "GF_AUTH_OAUTH_AUTO_LOGIN" = "false" + # Optionally map user groups to Grafana roles + "GF_AUTH_GENERIC_OAUTH_ROLE_ATTRIBUTE_PATH" = "contains(groups, 'Grafana Admins') && 'Admin' || contains(groups, 'Grafana Editors') && 'Editor' || 'Viewer'" + + } +} diff --git a/authentik.old/groups.tf b/authentik.old/groups.tf new file mode 100644 index 0000000..20129db --- /dev/null +++ b/authentik.old/groups.tf @@ -0,0 +1,7 @@ +data "authentik_group" "admins" { + name = "authentik Admins" +} + +resource "authentik_group" "arr-users" { + name = "arr_users" +} diff --git a/authentik.old/immich.tf b/authentik.old/immich.tf new file mode 100644 index 0000000..50fc71f --- /dev/null +++ b/authentik.old/immich.tf @@ -0,0 +1,69 @@ +#data "authentik_flow" "default-provider-authorization-implicit-consent" { +# slug = "default-provider-authorization-implicit-consent" +#} +# +#data "authentik_property_mapping_provider_scope" "scope-email" { +# name = "authentik default OAuth Mapping: OpenID 'email'" +#} +# +#data "authentik_property_mapping_provider_scope" "scope-profile" { +# name = "authentik default OAuth Mapping: OpenID 'profile'" +#} +# +#data "authentik_property_mapping_provider_scope" "scope-openid" { +# name = "authentik default OAuth Mapping: OpenID 'openid'" +#} +# +resource "random_id" "immich_client_id" { + byte_length = 16 +} + +resource "authentik_provider_oauth2" "immich" { + name = "Immich" + # Required. You can use the output of: + # $ openssl rand -hex 16 + client_id = random_id.immich_client_id.id + + # Optional: will be generated if not provided + # client_secret = "my_client_secret" + + authorization_flow = data.authentik_flow.default-provider-authorization-implicit-consent.id + invalidation_flow = data.authentik_flow.default-invalidation-flow.id + + allowed_redirect_uris = [ + { + matched_mode = "strict" + url = "app.immich:///oauth-callback", + }, + { + matched_mode = "strict" + url = "https://photos.lab.cowley.tech/auth/login", + }, + { + matched_mode = "strict" + url = "https://photos.lab.cowley.tech/user-settings", + } + ] + property_mappings = [ + data.authentik_property_mapping_provider_scope.scope-email.id, + data.authentik_property_mapping_provider_scope.scope-profile.id, + data.authentik_property_mapping_provider_scope.scope-openid.id, + ] + lifecycle { + ignore_changes = [ + signing_key, + authentication_flow, + ] + } +} + +resource "authentik_application" "immich" { + name = "Immich" + slug = "immich" + protocol_provider = authentik_provider_oauth2.immich.id +} + +resource "local_file" "foo" { + content = authentik_provider_oauth2.immich.client_secret + filename = "${path.module}/foo.bar" +} diff --git a/authentik.old/jellyfin.tf b/authentik.old/jellyfin.tf new file mode 100644 index 0000000..c1dd225 --- /dev/null +++ b/authentik.old/jellyfin.tf @@ -0,0 +1,50 @@ +resource "random_id" "jellyfin_client_id" { + byte_length = 16 +} + +resource "authentik_provider_oauth2" "jellyfin" { + name = "Jellyfin" + client_id = random_id.jellyfin_client_id.id + + authorization_flow = data.authentik_flow.default-provider-authorization-implicit-consent.id + invalidation_flow = data.authentik_flow.default-invalidation-flow.id + + allowed_redirect_uris = [ + { + matched_mode = "strict", + url = "https://jellyfin.lab.cowley.tech/sso/OID/start/authentik", + }, + { + matched_mode = "regex", + url = ".*", + } + ] + + property_mappings = [ + data.authentik_property_mapping_provider_scope.scope-email.id, + data.authentik_property_mapping_provider_scope.scope-profile.id, + data.authentik_property_mapping_provider_scope.scope-openid.id, + ] + lifecycle { + ignore_changes = [ + signing_key, + authentication_flow, + ] + } +} + +resource "authentik_application" "jellyfin" { + name = "Jellyfin" + slug = "jellyfin" + protocol_provider = authentik_provider_oauth2.jellyfin.id + meta_launch_url = "https://jellyfin.lab.cowley.tech/sso/OID/start/authentik" +} +resource "kubernetes_secret" "jellyfin_oidc" { + metadata { + name = "jellyfin-oidc" + namespace = "jellyfin" + } + data = { + client-secret = authentik_provider_oauth2.jellyfin.client_secret + } +} diff --git a/authentik/lidarr.tf b/authentik.old/lidarr.tf similarity index 100% rename from authentik/lidarr.tf rename to authentik.old/lidarr.tf diff --git a/authentik.old/nextcloud.tf b/authentik.old/nextcloud.tf new file mode 100644 index 0000000..5eb75c1 --- /dev/null +++ b/authentik.old/nextcloud.tf @@ -0,0 +1,75 @@ +#data "authentik_property_mapping_provider_scope" "nextcloud" { +# name = "Nextcloud Profile" +#} +resource "authentik_property_mapping_provider_scope" "nextcloud-scope" { + name = "Nextcloud Profile" + scope_name = "profile" + expression = <