-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathokta_vault.tf
111 lines (101 loc) · 3.23 KB
/
okta_vault.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Okta config
resource "okta_group" "vault-admins" {
name = "vault-admins-${var.application_name}"
description = ""
}
resource "okta_group" "vault-devs" {
name = "vault-devs-${var.application_name}"
description = ""
}
resource "okta_app_oauth" "vault" {
label = "vault-${var.application_name}"
type = "web"
grant_types = ["authorization_code", "implicit", "refresh_token"]
redirect_uris = ["${var.vault_address}/ui/vault/auth/${var.okta_mount_path}/oidc/callback",
# "${var.vault_address}/v1/auth/${var.okta_mount_path}/oidc/callback",
# the localhost on the cli port, usually 8250, is required below if you want to use CLI-based auth, ie
# $ vault login -method=oidc -path=okta_oidc role=okta_admin
"http://localhost:${var.cli_port}/oidc/callback"
]
response_types = ["id_token", "code"]
consent_method = "REQUIRED"
post_logout_redirect_uris = [var.vault_address]
login_uri = "${var.vault_address}/ui/vault/auth?namespace=%2F${var.application_name}&with=${var.okta_mount_path}%2F"
refresh_token_rotation = "STATIC"
lifecycle {
ignore_changes = [groups]
}
groups_claim {
type = "FILTER"
filter_type = "STARTS_WITH"
name = "groups"
value = "vault"
}
login_mode = "SPEC"
login_scopes = ["openid", "email", "profile"]
hide_web = false
hide_ios = false
}
resource "okta_app_oauth_api_scope" "vault" {
app_id = okta_app_oauth.vault.id
issuer = var.okta_base_url_full
scopes = ["okta.groups.read", "okta.users.read.self"]
}
resource "okta_app_group_assignments" "vault-groups" {
app_id = okta_app_oauth.vault.id
group {
id = okta_group.vault-admins.id
}
group {
id = okta_group.vault-devs.id
}
}
resource "okta_auth_server" "vault" {
audiences = [var.okta_auth_audience]
description = ""
name = var.application_name
issuer_mode = var.okta_issue_mode
status = "ACTIVE"
}
resource "okta_auth_server_claim" "vault" {
auth_server_id = okta_auth_server.vault.id
name = "groups"
value_type = "GROUPS"
group_filter_type = "STARTS_WITH"
value = "vault-"
scopes = ["profile"]
claim_type = "IDENTITY"
always_include_in_token = true
}
resource "okta_auth_server_policy" "vault" {
auth_server_id = okta_auth_server.vault.id
status = "ACTIVE"
name = "vault policy"
description = ""
priority = 1
client_whitelist = ["ALL_CLIENTS"]
}
resource "okta_auth_server_policy_rule" "vault" {
auth_server_id = okta_auth_server.vault.id
policy_id = okta_auth_server_policy.vault.id
status = "ACTIVE"
name = "default"
priority = 1
group_whitelist = ["EVERYONE"]
scope_whitelist = ["*"]
grant_type_whitelist = ["client_credentials", "authorization_code", "implicit"]
}
# Add user to groups
data "okta_user" "vault" {
search {
name = "profile.email"
value = var.okta_user_email
}
}
resource "okta_user_group_memberships" "vault" {
user_id = data.okta_user.vault.id
groups = [
okta_group.vault-admins.id,
okta_group.vault-devs.id,
]
}