Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/helm-charts' into helm-charts
Browse files Browse the repository at this point in the history
  • Loading branch information
Apoorva64 committed Oct 18, 2024
2 parents ba623a1 + c5e22a3 commit a2c6e3f
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 2 deletions.
40 changes: 40 additions & 0 deletions terraform/keycloak/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
resource "keycloak_openid_client" "backend" {
access_type = "CONFIDENTIAL"
client_id = "backend"
realm_id = keycloak_realm.poulet.id
valid_redirect_uris = [
"*"
]
standard_flow_enabled = true
direct_access_grants_enabled = true
service_accounts_enabled = true
client_secret = var.client_secret
}

resource "keycloak_role" "backend_doctor" {
realm_id = keycloak_realm.poulet.id
client_id = keycloak_openid_client.backend.id
name = "doctor"
description = "Role with doctor privilege"
}

resource "keycloak_role" "backend_nurse" {
realm_id = keycloak_realm.poulet.id
client_id = keycloak_openid_client.backend.id
name = "nurse"
description = "Role with nrse privilege"
}

resource "keycloak_role" "backend_patient" {
realm_id = keycloak_realm.poulet.id
client_id = keycloak_openid_client.backend.id
name = "patient"
description = "Role with patient privilege"
}

resource "keycloak_role" "backend_familly" {
realm_id = keycloak_realm.poulet.id
client_id = keycloak_openid_client.backend.id
name = "familly"
description = "Role with familly privilege"
}
40 changes: 40 additions & 0 deletions terraform/keycloak/frontend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
resource "keycloak_openid_client" "frontend" {
access_type = "CONFIDENTIAL"
client_id = "frontend"
realm_id = keycloak_realm.poulet.id
valid_redirect_uris = [
"*"
]
standard_flow_enabled = true
direct_access_grants_enabled = true
service_accounts_enabled = true
client_secret = var.client_secret
}

resource "keycloak_role" "frontend_doctor" {
realm_id = keycloak_realm.poulet.id
client_id = keycloak_openid_client.frontend.id
name = "doctor"
description = "Role with doctor privilege"
}

resource "keycloak_role" "frontend_nurse" {
realm_id = keycloak_realm.poulet.id
client_id = keycloak_openid_client.frontend.id
name = "nurse"
description = "Role with nrse privilege"
}

resource "keycloak_role" "frontend_patient" {
realm_id = keycloak_realm.poulet.id
client_id = keycloak_openid_client.frontend.id
name = "patient"
description = "Role with patient privilege"
}

resource "keycloak_role" "frontend_familly" {
realm_id = keycloak_realm.poulet.id
client_id = keycloak_openid_client.frontend.id
name = "familly"
description = "Role with familly privilege"
}
36 changes: 34 additions & 2 deletions terraform/keycloak/realm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,46 @@ resource "keycloak_role" "admin_role" {
realm_id = keycloak_realm.poulet.id
name = "admin"
composite_roles = [
keycloak_role.grafana_admin.id
keycloak_role.grafana_admin.id,
keycloak_role.backend_doctor.id,
keycloak_role.frontend_doctor.id
]
}

resource "keycloak_role" "doctor_role" {
realm_id = keycloak_realm.poulet.id
name = "doctor"
composite_roles = [
keycloak_role.grafana_viewer.id
keycloak_role.grafana_viewer.id,
keycloak_role.backend_doctor.id,
keycloak_role.frontend_doctor.id
]
}

resource "keycloak_role" "nurse_role" {
realm_id = keycloak_realm.poulet.id
name = "nurse"
composite_roles = [
keycloak_role.grafana_viewer.id,
keycloak_role.backend_nurse.id,
keycloak_role.frontend_nurse.id
]
}

resource "keycloak_role" "patient_role" {
realm_id = keycloak_realm.poulet.id
name = "patient"
composite_roles = [
keycloak_role.backend_patient.id,
keycloak_role.frontend_patient.id
]
}

resource "keycloak_role" "familly_role" {
realm_id = keycloak_realm.poulet.id
name = "familly"
composite_roles = [
keycloak_role.backend_familly.id,
keycloak_role.frontend_familly.id
]
}
104 changes: 104 additions & 0 deletions terraform/keycloak/user.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
resource "keycloak_user" "poulet_admin" {
realm_id = keycloak_realm.poulet.id
username = "poulet_admin"
enabled = true

email = "[email protected]"
email_verified = true

first_name = "John"
last_name = "Doe"

initial_password {
value = "admin"
temporary = false
}
}

resource "keycloak_user_roles" "admin_role" {
realm_id = keycloak_realm.poulet.id
user_id = keycloak_user.poulet_admin.id

role_ids = [
keycloak_role.admin_role.id
]
}

resource "keycloak_user" "doctor" {
realm_id = keycloak_realm.poulet.id
username = "doctor"
Expand All @@ -22,4 +48,82 @@ resource "keycloak_user_roles" "doctor_role" {
role_ids = [
keycloak_role.doctor_role.id
]
}

resource "keycloak_user" "nurse" {
realm_id = keycloak_realm.poulet.id
username = "nurse"
enabled = true

email = "[email protected]"
email_verified = true

first_name = "John"
last_name = "Doe"

initial_password {
value = "nurse"
temporary = false
}
}

resource "keycloak_user_roles" "nurse_role" {
realm_id = keycloak_realm.poulet.id
user_id = keycloak_user.nurse.id

role_ids = [
keycloak_role.nurse_role.id
]
}

resource "keycloak_user" "patient" {
realm_id = keycloak_realm.poulet.id
username = "patient"
enabled = true

email = "[email protected]"
email_verified = true

first_name = "John"
last_name = "Doe"

initial_password {
value = "patient"
temporary = false
}
}

resource "keycloak_user_roles" "patient_role" {
realm_id = keycloak_realm.poulet.id
user_id = keycloak_user.patient.id

role_ids = [
keycloak_role.patient_role.id
]
}

resource "keycloak_user" "familly" {
realm_id = keycloak_realm.poulet.id
username = "familly"
enabled = true

email = "[email protected]"
email_verified = true

first_name = "John"
last_name = "Doe"

initial_password {
value = "familly"
temporary = false
}
}

resource "keycloak_user_roles" "familly_role" {
realm_id = keycloak_realm.poulet.id
user_id = keycloak_user.familly.id

role_ids = [
keycloak_role.familly_role.id
]
}

0 comments on commit a2c6e3f

Please sign in to comment.