Skip to content

Commit 32bf440

Browse files
authored
Connected accounts 1 (#27)
* adding microsoft login for connected accounts * CA & TV continued * CA & TV with cli working * FCAT with access_token
1 parent f75d20a commit 32bf440

File tree

6 files changed

+118
-18
lines changed

6 files changed

+118
-18
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,6 @@ Sample access_token. `org_id` is nullable for donors.
802802
| 08 | [s-08.txt](./videos/08/s-08.txt) | [s-08.mp4](./videos/08/s-08.mp4) | Donor | Bulk import & Forms |
803803
| 09 | [s-09.txt](./videos/09/s-09.txt) | [s-09.mp4](./videos/09/s-09.mp4) | Donor | MCD |
804804
| 10 | [s-10.txt](./videos/10/s-10.txt) | [s-10.mp4](./videos/10/s-10.mp4) | Donor | User events |
805-
| 11 | [s-11.txt](./videos/11/s-11.txt) | [s-11.mp4](./videos/11/s-11.mp4) | Business | Connected Account |
805+
| 11 | [s-11.txt](./videos/11/s-11.txt) | [s-11.mp4](./videos/11/s-11.mp4) | Business | Token Vault, Connected Account |
806806
| 12 | [s-12.txt](./videos/12/s-12.txt) | [s-12.mp4](./videos/12/s-12.mp4) | Business | CIBA |
807807
| 13 | [s-13.txt](./videos/13/s-13.txt) | [s-13.mp4](./videos/13/s-13.mp4) | Both | Closing thoughts |

tf/02-donor-website.tf

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,26 @@ resource "auth0_client" "donor" {
125125
}
126126

127127
organization_usage = "deny"
128+
129+
grant_types = [
130+
"authorization_code",
131+
"password",
132+
"http://auth0.com/oauth/grant-type/password-realm",
133+
#"urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",
134+
]
128135
}
129136

130137
# donor cli client
131138
resource "auth0_client" "donor-cli" {
132139
name = "Donor CLI"
133140
description = "Donor CLI client"
134-
app_type = "spa"
141+
app_type = "regular_web"
135142
oidc_conformant = true
136143
is_first_party = true
137144

138145
callbacks = [
139-
"https://donor.${var.top_level_domain}"
146+
"https://donor.${var.top_level_domain}",
147+
"https://jwt.io"
140148
]
141149

142150
allowed_logout_urls = [
@@ -148,13 +156,20 @@ resource "auth0_client" "donor-cli" {
148156
}
149157

150158
grant_types = [
159+
"implicit",
151160
"password",
152-
"http://auth0.com/oauth/grant-type/password-realm"
161+
"http://auth0.com/oauth/grant-type/password-realm",
162+
"urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",
163+
"refresh_token"
153164
]
154165

155166
organization_usage = "deny"
156167
}
157168

169+
output "donor-cli-client-id" {
170+
value = auth0_client.donor-cli.client_id
171+
}
172+
158173
# Generate auth config file for donor SPA
159174
resource "local_file" "donor_auth_config_json" {
160175
filename = "${path.module}/../donor/spa/public/auth_config.json"

tf/03-social-login.tf

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,6 @@ resource "auth0_connection_clients" "linkedin-clients" {
117117
]
118118
}
119119

120-
## Google Social
121-
data "auth0_connection" "google-oauth2" {
122-
name = "google-oauth2"
123-
}
124-
125-
126-
resource "auth0_connection_clients" "google-clients" {
127-
connection_id = data.auth0_connection.google-oauth2.id
128-
enabled_clients = [
129-
//auth0_client.donor.client_id,
130-
]
131-
}
132-
133120
## Facebook social
134121
# VISIT https://developers.facebook.com/apps/1505837500618862/fb-login/settings/
135122
resource "auth0_connection" "facebook" {
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
data "auth0_resource_server" "my-account" {
2+
identifier = "https://${var.auth0_domain}/me/"
3+
}
4+
5+
resource "auth0_client_grant" "donor-cli-grants" {
6+
audience = data.auth0_resource_server.my-account.identifier
7+
client_id = auth0_client.donor-cli.id
8+
scopes = [
9+
// authentication methods
10+
"read:me:authentication_methods",
11+
"delete:me:authentication_methods",
12+
"update:me:authentication_methods",
13+
"create:me:authentication_methods",
14+
// factors
15+
"read:me:factors",
16+
// connected_accounts
17+
"create:me:connected_accounts",
18+
"read:me:connected_accounts",
19+
"delete:me:connected_accounts"
20+
]
21+
subject_type = "user"
22+
}
23+
24+
data "auth0_client" "donor-api-client" {
25+
name = auth0_resource_server.donor_api.name
26+
}
27+
28+
/*
29+
resource "auth0_client_grant" "donor-grants" {
30+
audience = data.auth0_resource_server.my-account.identifier
31+
client_id = auth0_client.donor.id
32+
scopes = [
33+
// authentication methods
34+
"read:me:authentication_methods",
35+
"delete:me:authentication_methods",
36+
"update:me:authentication_methods",
37+
"create:me:authentication_methods",
38+
// factors
39+
"read:me:factors",
40+
// connected_accounts
41+
"create:me:connected_accounts",
42+
"read:me:connected_accounts",
43+
"delete:me:connected_accounts"
44+
]
45+
subject_type = "user"
46+
}
47+
*/
48+
49+
## social connection to connected accounts
50+
# VISIT https://entra.microsoft.com/#view/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/~/Overview/appId/21003461-3662-430d-a8af-bc50abacfe6e/isMSAApp~/false
51+
# VISIT https://manage.auth0.com/dashboard/au/replate-prd/connections/social/con_nvtYytFItnYhBirE/settings
52+
resource "auth0_connection" "windowslive" {
53+
name = "Microsoft"
54+
strategy = "windowslive"
55+
56+
authentication {
57+
active = false
58+
}
59+
60+
connected_accounts {
61+
active = true
62+
}
63+
64+
options {
65+
client_id = var.microsoft_client_id
66+
client_secret = var.microsoft_client_secret
67+
strategy_version = 2
68+
scopes = [
69+
"signin",
70+
"offline_access",
71+
"graph_calendars",
72+
"graph_user"
73+
]
74+
set_user_root_attributes = "on_each_login"
75+
}
76+
}
77+
78+
resource "auth0_connection_clients" "windowslive-clients" {
79+
connection_id = auth0_connection.windowslive.id
80+
enabled_clients = [
81+
auth0_client.donor-cli.client_id,
82+
auth0_client.donor.client_id,
83+
data.auth0_client.donor-api-client.client_id
84+
]
85+
}

tf/providers.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
auth0 = {
55
source = "auth0/auth0"
6-
version = ">= 1.32"
6+
version = ">= 1.33"
77
}
88
cloudflare = {
99
source = "cloudflare/cloudflare"

tf/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ variable "linkedin_client_id" {
101101
variable "linkedin_client_secret" {
102102
type = string
103103
description = "LinkedIn social connection client_secret"
104+
sensitive = true
104105
}
105106

106107
variable "linkedin_user_email" {
@@ -117,13 +118,25 @@ variable "facebook_client_id" {
117118
variable "facebook_client_secret" {
118119
type = string
119120
description = "Facebook social connection client_secret"
121+
sensitive = true
120122
}
121123

122124
variable "facebook_user_email" {
123125
type = string
124126
description = "database user with a matching email for facebook social"
125127
}
126128

129+
## Microsoft Social
130+
variable "microsoft_client_id" {
131+
type = string
132+
description = "Microsoft social connection client_id"
133+
}
134+
135+
variable "microsoft_client_secret" {
136+
type = string
137+
description = "Microsoft social connection client_secret"
138+
sensitive = true
139+
}
127140

128141
## AoB
129142
variable "default-password" {

0 commit comments

Comments
 (0)