forked from keycloak/terraform-provider-keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfederated_user_example.tf
95 lines (88 loc) · 4.03 KB
/
federated_user_example.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
resource "keycloak_realm" "source_realm" {
realm = "source_realm"
enabled = true
}
resource "keycloak_openid_client" "destination_client" {
realm_id = keycloak_realm.source_realm.id
name = "destination_client"
client_id = "destination_client"
client_secret = "secret"
description = "a client used by the destination realm"
access_type = "CONFIDENTIAL"
standard_flow_enabled = true
valid_redirect_uris = [
"http://localhost:8080/*",
]
}
//do not get confused this just to have multiple federate idps on the destination realm
resource "keycloak_openid_client" "destination_double_client" {
realm_id = keycloak_realm.source_realm.id
name = "destination_double_client"
client_id = "destination_double_client"
client_secret = "secret2"
description = "a second client used by the destination realm"
access_type = "CONFIDENTIAL"
standard_flow_enabled = true
valid_redirect_uris = [
"http://localhost:8080/*",
]
}
resource "keycloak_user" "source_user" {
realm_id = keycloak_realm.source_realm.id
username = "source"
email = "[email protected]"
first_name = "source"
last_name = "source"
initial_password {
value = "source"
temporary = false
}
}
resource "keycloak_realm" "destination_realm" {
realm = "destination_realm"
enabled = true
}
resource keycloak_oidc_identity_provider source_oidc_idp {
realm = keycloak_realm.destination_realm.id
alias = "source"
authorization_url = "http://localhost:8080/auth/realms/${keycloak_realm.source_realm.id}/protocol/openid-connect/auth"
token_url = "http://localhost:8080/auth/realms/${keycloak_realm.source_realm.id}/protocol/openid-connect/token"
user_info_url = "http://localhost:8080/auth/realms/${keycloak_realm.source_realm.id}/protocol/openid-connect/userinfo"
jwks_url = "http://localhost:8080/auth/realms/${keycloak_realm.source_realm.id}/protocol/openid-connect/certs"
validate_signature = true
client_id = keycloak_openid_client.destination_client.client_id
client_secret = keycloak_openid_client.destination_client.client_secret
default_scopes = "openid"
}
//do not get confused this second idp towards source_realm, this could a completly different idp
resource keycloak_oidc_identity_provider second_source_oidc_idp {
realm = keycloak_realm.destination_realm.id
alias = "source2"
authorization_url = "http://localhost:8080/auth/realms/${keycloak_realm.source_realm.id}/protocol/openid-connect/auth"
token_url = "http://localhost:8080/auth/realms/${keycloak_realm.source_realm.id}/protocol/openid-connect/token"
user_info_url = "http://localhost:8080/auth/realms/${keycloak_realm.source_realm.id}/protocol/openid-connect/userinfo"
jwks_url = "http://localhost:8080/auth/realms/${keycloak_realm.source_realm.id}/protocol/openid-connect/certs"
validate_signature = true
client_id = keycloak_openid_client.destination_double_client.client_id
client_secret = keycloak_openid_client.destination_double_client.client_secret
default_scopes = "openid"
}
resource "keycloak_user" "destination_user" {
realm_id = keycloak_realm.destination_realm.id
username = "my_destination_username"
email = "[email protected]"
first_name = "Destination_source"
last_name = "Destination_source"
//federated link through source idp
federated_identity {
identity_provider = keycloak_oidc_identity_provider.source_oidc_idp.alias
user_id = keycloak_user.source_user.id
user_name = keycloak_user.source_user.username
}
//federated link through second source idp
federated_identity {
identity_provider = keycloak_oidc_identity_provider.second_source_oidc_idp.alias
user_id = keycloak_user.source_user.id
user_name = keycloak_user.source_user.username
}
}