Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 387e649

Browse files
authored
Merge pull request #29 from presentium/main
update prod
2 parents 5c4de51 + 09351de commit 387e649

File tree

9 files changed

+116
-11
lines changed

9 files changed

+116
-11
lines changed

Diff for: applications/.tfvars.sample

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
authentik_url = ""
2+
authentik_api_key = ""

Diff for: applications/_vars.tf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
variable "authentik_url" {
2+
description = "Authentik management URL"
3+
}
4+
5+
variable "authentik_api_key" {
6+
description = "Authentik management API key"
7+
sensitive = true
8+
}

Diff for: applications/main.tf

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ terraform {
2020

2121
// Provider configuration
2222

23-
# provider "authentik" {
24-
# token = ""
25-
# url = ""
26-
#}
23+
provider "authentik" {
24+
url = var.authentik_url
25+
token = var.authentik_api_key
26+
}
2727

2828
# provider "vault" {
2929
# address = ""
@@ -40,9 +40,9 @@ module "authentik" {
4040
}
4141
}
4242

43-
module "vault" {
44-
source = "./modules/vault"
45-
providers = {
46-
vault = vault
47-
}
48-
}
43+
# module "vault" {
44+
# source = "./modules/vault"
45+
# providers = {
46+
# vault = vault
47+
# }
48+
# }

Diff for: applications/modules/authentik/_data.tf

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
data "authentik_flow" "default-implicit" {
2+
slug = "default-provider-authorization-implicit-consent"
3+
}
4+
5+
data "authentik_flow" "default-explicit" {
6+
slug = "default-provider-authorization-explicit-consent"
7+
}
8+
9+
data "authentik_scope_mapping" "scope-email" {
10+
scope_name = "email"
11+
name = "authentik default OAuth Mapping: OpenID 'email'"
12+
}
13+
14+
data "authentik_scope_mapping" "scope-profile" {
15+
scope_name = "profile"
16+
name = "authentik default OAuth Mapping: OpenID 'profile'"
17+
}
18+
19+
data "authentik_scope_mapping" "scope-openid" {
20+
scope_name = "roles"
21+
name = "authentik default OAuth Mapping: OpenID 'openid'"
22+
}

Diff for: applications/modules/authentik/groups-presentium.tf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
resource "authentik_group" "students" {
2+
name = "Presentium Students"
3+
}
4+
5+
resource "authentik_group" "teachers" {
6+
name = "Presentium Teachers"
7+
parent = authentik_group.students.id
8+
}
9+
10+
resource "authentik_group" "admins" {
11+
name = "Presentium Admins"
12+
parent = authentik_group.teachers.id
13+
is_superuser = true
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
resource "authentik_scope_mapping" "scope-roles" {
2+
name = "Presentium Roles"
3+
scope_name = "roles"
4+
expression = <<-EOT
5+
roles = []
6+
if ak_is_group_member(request.user, name="${authentik_group.students.name}"):
7+
roles.append("student")
8+
if ak_is_group_member(request.user, name="${authentik_group.teachers.name}"):
9+
roles.append("teacher")
10+
if ak_is_group_member(request.user, name="${authentik_group.admins.name}"):
11+
roles.append("admin")
12+
13+
return {
14+
"roles": roles
15+
}
16+
EOT
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
resource "authentik_provider_oauth2" "presentium" {
2+
name = "oidc-presentium"
3+
client_id = "ca884da2-1542-46a7-be60-5c42a513451a"
4+
5+
authorization_flow = data.authentik_flow.default-explicit.id
6+
7+
redirect_uris = [
8+
"https://app.presentium.ch/auth/oidc/callback", # Production domain
9+
"https://staging.presentium.ch/auth/oidc/callback", # Staging domain
10+
"https://dashboard-presentium.nuxt.dev/auth/oidc/callback", # NuxtHub domain
11+
"https://[\\w-]+.dashboard-1as.pages.dev/auth/oidc/callback", # PR / preview domains
12+
]
13+
14+
property_mappings = [
15+
data.authentik_scope_mapping.scope-email.id,
16+
data.authentik_scope_mapping.scope-profile.id,
17+
data.authentik_scope_mapping.scope-openid.id,
18+
authentik_scope_mapping.scope-roles.id,
19+
]
20+
}
21+
22+
resource "authentik_application" "presentium" {
23+
name = "Presentium"
24+
slug = "presentium"
25+
protocol_provider = authentik_provider_oauth2.presentium.id
26+
meta_icon = "https://avatars.githubusercontent.com/u/174350723?s=4000&v=4"
27+
}

Diff for: dockerfiles/argocd.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ RUN \
4848

4949
RUN chmod +x /gitops-tools/* && ln -sf /gitops-tools/helm-plugins/helm-secrets/scripts/wrapper/helm.sh /usr/local/sbin/helm
5050

51-
USER argocd
51+
USER $ARGOCD_USER_ID

Diff for: infrastructure/modules/aws/eks/iam.tf

+15
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ module "vpc_cni_irsa" {
1414
}
1515
}
1616

17+
module "alb_controller_irsa" {
18+
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
19+
20+
role_name = "PRES-ALB-CONTROLLER-${upper(module.eks.cluster_name)}"
21+
22+
attach_load_balancer_controller_policy = true
23+
24+
oidc_providers = {
25+
main = {
26+
provider_arn = module.eks.oidc_provider_arn
27+
namespace_service_accounts = ["kube-system:aws-load-balancer-controller"]
28+
}
29+
}
30+
}
31+
1732
module "sops_kms_irsa" {
1833
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
1934

0 commit comments

Comments
 (0)