-
Notifications
You must be signed in to change notification settings - Fork 6
/
conditional_access.prerequisite.tf
76 lines (62 loc) · 2.18 KB
/
conditional_access.prerequisite.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# ---------------------------
# CONDITIONAL ACCESS POLICIES
# ---------------------------
# Category: Prerequisite
## CAP001
### Create exclude group
resource "azuread_group" "cap001_exclude" {
count = var.cap001_create == true ? 1 : 0
display_name = "${var.group_name_prefix}-CA-Exclude-CAP001"
security_enabled = true
prevent_duplicate_names = true
}
### Create policy
resource "azuread_conditional_access_policy" "cap001" {
count = var.cap001_create == true ? 1 : 0
display_name = "CAP001-All: Block Legacy Authentication for All users when OtherClients-v1.0"
state = var.reporting_only_for_all_policies == true ? "enabledForReportingButNotEnforced" : var.cap001_state
conditions {
users {
included_users = ["All"]
excluded_groups = [azuread_group.cap001_exclude[0].object_id]
excluded_users = var.emergency_access_upn != null ? [data.azuread_user.emergency_access_upn[0].object_id] : null
}
applications {
included_applications = ["All"]
}
client_app_types = ["other"]
}
grant_controls {
built_in_controls = ["block"]
operator = "OR"
}
}
## CAP002
### Create exclude group
resource "azuread_group" "cap002_exclude" {
count = var.cap002_create == true ? 1 : 0
display_name = "${var.group_name_prefix}-CA-Exclude-CAP002"
security_enabled = true
prevent_duplicate_names = true
}
### Create policy
resource "azuread_conditional_access_policy" "cap002" {
count = var.cap002_create == true ? 1 : 0
display_name = "CAP002-O365: Grant Exchange ActiveSync Clients for All users when Approved App-v1.0"
state = var.reporting_only_for_all_policies == true ? "enabledForReportingButNotEnforced" : var.cap002_state
conditions {
users {
included_users = ["All"]
excluded_groups = [azuread_group.cap002_exclude[0].object_id]
excluded_users = var.emergency_access_upn != null ? [data.azuread_user.emergency_access_upn[0].object_id] : null
}
applications {
included_applications = ["All"]
}
client_app_types = ["exchangeActiveSync"]
}
grant_controls {
built_in_controls = ["approvedApplication"]
operator = "OR"
}
}