-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement account linking for incoming login ID #4372
ref DEV-1233
- Loading branch information
Showing
80 changed files
with
2,375 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"identifier": "preferred_username", | ||
"records": [ | ||
{ | ||
"preferred_username": "mock" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
INSERT INTO _auth_identity ( | ||
"id", | ||
"app_id", | ||
"type", | ||
"user_id", | ||
"created_at", | ||
"updated_at" | ||
) VALUES ( | ||
'{{ .AppID }}__google__', | ||
'{{ .AppID }}', | ||
'oauth', | ||
(SELECT b.user_id | ||
FROM _auth_identity_login_id a | ||
JOIN _auth_identity b | ||
ON a.id = b.id | ||
WHERE a.login_id = 'mock' | ||
AND a.app_id = '{{ .AppID }}' | ||
LIMIT 1 | ||
), | ||
NOW(), | ||
NOW() | ||
); | ||
|
||
INSERT INTO _auth_identity_oauth ( | ||
"id", | ||
"app_id", | ||
"provider_type", | ||
"provider_keys", | ||
"provider_user_id", | ||
"claims", | ||
"profile" | ||
) VALUES ( | ||
'{{ .AppID }}__google__', | ||
'{{ .AppID }}', | ||
'google', | ||
'{}', | ||
'mock', | ||
'{"email": "[email protected]"}', | ||
'{"email": "[email protected]"}' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"identifier": "preferred_username", | ||
"records": [ | ||
{ | ||
"preferred_username": "mock", | ||
"phone_number": "+85298765432" | ||
} | ||
] | ||
} |
69 changes: 69 additions & 0 deletions
69
e2e/tests/account_linking/incoming_login_id_action_error.test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Account linking - Incoming Login ID - action=error | ||
authgear.yaml: | ||
override: | | ||
authentication: | ||
identities: | ||
- login_id | ||
- oauth | ||
identity: | ||
login_id: | ||
keys: | ||
- type: email | ||
- type: username | ||
oauth: | ||
providers: | ||
- alias: google | ||
client_id: "google" | ||
type: google | ||
account_linking: | ||
login_id: | ||
- key: email | ||
action: error | ||
user_profile: | ||
pointer: "/email" | ||
authentication_flow: | ||
signup_flows: | ||
- name: f1 | ||
steps: | ||
- type: identify | ||
one_of: | ||
- identification: email | ||
- identification: oauth | ||
before: | ||
- type: user_import | ||
user_import: google_user.json | ||
- type: custom_sql | ||
custom_sql: | ||
path: google_user.sql | ||
steps: | ||
- action: "create" | ||
input: | | ||
{ | ||
"type": "signup", | ||
"name": "f1" | ||
} | ||
output: | ||
result: | | ||
{ | ||
"action": { | ||
"type": "identify" | ||
} | ||
} | ||
- action: input | ||
input: | | ||
{ | ||
"identification": "email", | ||
"login_id": "[email protected]" | ||
} | ||
output: | ||
error: | | ||
{ | ||
"reason": "InvariantViolated", | ||
"info": { | ||
"cause": { | ||
"kind": "DuplicatedIdentity" | ||
} | ||
} | ||
} |
140 changes: 140 additions & 0 deletions
140
e2e/tests/account_linking/incoming_login_id_create_authenticator_before.test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
name: Account linking - Incoming Login ID - create_authenticator before it | ||
authgear.yaml: | ||
override: | | ||
authentication: | ||
identities: | ||
- login_id | ||
- oauth | ||
identity: | ||
login_id: | ||
keys: | ||
- type: email | ||
- type: username | ||
oauth: | ||
providers: | ||
- alias: google | ||
client_id: "google" | ||
type: google | ||
account_linking: | ||
login_id: | ||
- key: email | ||
action: login_and_link | ||
user_profile: | ||
pointer: "/email" | ||
authentication_flow: | ||
signup_flows: | ||
- name: f1 | ||
steps: | ||
- type: create_authenticator | ||
one_of: | ||
- authentication: primary_password | ||
- type: identify | ||
one_of: | ||
- identification: email | ||
login_flows: | ||
- name: f1 | ||
steps: | ||
- name: identify | ||
type: identify | ||
one_of: | ||
- identification: oauth | ||
- identification: email | ||
steps: | ||
- type: authenticate | ||
one_of: | ||
- authentication: primary_password | ||
before: | ||
- type: user_import | ||
user_import: google_user.json | ||
- type: custom_sql | ||
custom_sql: | ||
path: google_user.sql | ||
steps: | ||
- action: "create" | ||
input: | | ||
{ | ||
"type": "signup", | ||
"name": "f1" | ||
} | ||
output: | ||
result: | | ||
{ | ||
"action": { | ||
"type": "create_authenticator" | ||
} | ||
} | ||
- action: input | ||
input: | | ||
{ | ||
"authentication": "primary_password", | ||
"new_password": "12341234a" | ||
} | ||
output: | ||
result: | | ||
{ | ||
"action": { | ||
"type": "identify" | ||
} | ||
} | ||
- action: input | ||
input: | | ||
{ | ||
"identification": "email", | ||
"login_id": "[email protected]" | ||
} | ||
output: | ||
result: | | ||
{ | ||
"action": { | ||
"type": "identify", | ||
"identification": "email", | ||
"data": { | ||
"type": "account_linking_identification_data" | ||
} | ||
} | ||
} | ||
- action: input | ||
input: | | ||
{ | ||
"index": 0, | ||
"redirect_uri": "http://mock" | ||
} | ||
output: | ||
result: | | ||
{ | ||
"action": { | ||
"type": "identify", | ||
"identification": "oauth", | ||
"data": { | ||
"type": "oauth_data", | ||
"alias": "google", | ||
"oauth_provider_type": "google", | ||
"oauth_authorization_url": "[[string]]" | ||
} | ||
} | ||
} | ||
- action: oauth_redirect | ||
to: "{{ .prev.result.action.data.oauth_authorization_url }}" | ||
redirect_uri: http://mock | ||
output: | ||
result: | | ||
{ | ||
"query": "[[string]]" | ||
} | ||
- action: input | ||
input: | | ||
{ | ||
"query": "{{ .prev.result.query }}" | ||
} | ||
output: | ||
result: | | ||
{ | ||
"action": { | ||
"type": "finished" | ||
} | ||
} |
Oops, something went wrong.