-
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 minimal account linking for LDAP
ref DEV-1815
- Loading branch information
Showing
11 changed files
with
516 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,15 @@ var userData = ` | |
givenName: Duplicated | ||
sn: User | ||
mail: [email protected] | ||
- credential: | ||
password: mockpassword | ||
dn: cn=mock,ou=people,ou=HK,dc=authgear,dc=com | ||
uid: mock | ||
attributes: | ||
givenName: John | ||
sn: Doe | ||
mail: [email protected] | ||
` | ||
|
||
type LDAPRouteHandler struct { | ||
|
60 changes: 60 additions & 0 deletions
60
e2e/tests/account_linking/incoming_ldap_conflicts_login_id.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,60 @@ | ||
name: Account linking - Incoming LDAP - conflicts login ID error | ||
authgear.yaml: | ||
override: | | ||
authentication: | ||
identities: | ||
- login_id | ||
- ldap | ||
identity: | ||
ldap: | ||
servers: | ||
- name: ldap-server-1 | ||
url: ldap://127.0.0.1:8389 | ||
base_dn: dc=authgear,dc=com | ||
search_filter_template: (uid={{.Username}}) | ||
user_id_attribute_name: uid | ||
authentication_flow: | ||
signup_flows: | ||
- name: f1 | ||
steps: | ||
- type: identify | ||
one_of: | ||
- identification: ldap | ||
- identification: email | ||
before: | ||
- type: user_import | ||
user_import: email_users.json | ||
|
||
steps: | ||
- action: "create" | ||
input: | | ||
{ | ||
"type": "signup", | ||
"name": "f1" | ||
} | ||
output: | ||
result: | | ||
{ | ||
"action": { | ||
"type": "identify" | ||
} | ||
} | ||
- action: input | ||
input: | | ||
{ | ||
"identification": "ldap", | ||
"server_name": "ldap-server-1", | ||
"username": "mock", | ||
"password": "mockpassword" | ||
} | ||
output: | ||
error: | | ||
{ | ||
"reason": "InvariantViolated", | ||
"info": { | ||
"cause": { | ||
"kind": "DuplicatedIdentity" | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
e2e/tests/account_linking/incoming_ldap_conflicts_oauth.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,63 @@ | ||
name: Account linking - Incoming LDAP - conflicts OAuth error | ||
authgear.yaml: | ||
override: | | ||
authentication: | ||
identities: | ||
- ldap | ||
- oauth | ||
identity: | ||
ldap: | ||
servers: | ||
- name: ldap-server-1 | ||
url: ldap://127.0.0.1:8389 | ||
base_dn: dc=authgear,dc=com | ||
search_filter_template: (uid={{.Username}}) | ||
user_id_attribute_name: uid | ||
authentication_flow: | ||
signup_flows: | ||
- name: f1 | ||
steps: | ||
- type: identify | ||
one_of: | ||
- identification: ldap | ||
- 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": "ldap", | ||
"server_name": "ldap-server-1", | ||
"username": "mock", | ||
"password": "mockpassword" | ||
} | ||
output: | ||
error: | | ||
{ | ||
"reason": "InvariantViolated", | ||
"info": { | ||
"cause": { | ||
"kind": "DuplicatedIdentity" | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
e2e/tests/account_linking/incoming_login_id_conflicts_ldap.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,62 @@ | ||
name: Account linking - Incoming Login ID - conflicts LDAP error | ||
authgear.yaml: | ||
override: | | ||
authentication: | ||
identities: | ||
- login_id | ||
- ldap | ||
identity: | ||
login_id: | ||
keys: | ||
- type: email | ||
- type: username | ||
account_linking: | ||
login_id: | ||
- key: email | ||
action: error | ||
user_profile: | ||
pointer: "/email" | ||
authentication_flow: | ||
signup_flows: | ||
- name: f1 | ||
steps: | ||
- type: identify | ||
one_of: | ||
- identification: ldap | ||
- identification: email | ||
before: | ||
- type: custom_sql | ||
custom_sql: | ||
path: ldap_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" | ||
} | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
e2e/tests/account_linking/incoming_oauth_conflicts_ldap.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,91 @@ | ||
name: Account linking - Incoming OAuth - conflicts LDAP error | ||
authgear.yaml: | ||
override: | | ||
authentication: | ||
identities: | ||
- ldap | ||
- oauth | ||
identity: | ||
oauth: | ||
providers: | ||
- alias: google | ||
client_id: "google" | ||
type: google | ||
account_linking: | ||
oauth: | ||
- alias: google | ||
action: error | ||
oauth_claim: | ||
pointer: "/email" | ||
user_profile: | ||
pointer: "/email" | ||
authentication_flow: | ||
signup_flows: | ||
- name: f1 | ||
steps: | ||
- type: identify | ||
one_of: | ||
- identification: ldap | ||
- identification: oauth | ||
before: | ||
- type: custom_sql | ||
custom_sql: | ||
path: ldap_user.sql | ||
|
||
steps: | ||
- action: "create" | ||
input: | | ||
{ | ||
"type": "signup", | ||
"name": "f1" | ||
} | ||
output: | ||
result: | | ||
{ | ||
"action": { | ||
"type": "identify" | ||
} | ||
} | ||
- action: input | ||
input: | | ||
{ | ||
"identification": "oauth", | ||
"alias": "google", | ||
"redirect_uri": "http://mock" | ||
} | ||
output: | ||
result: | | ||
{ | ||
"action": { | ||
"type": "identify", | ||
"data": { | ||
"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: | ||
error: | | ||
{ | ||
"reason": "InvariantViolated", | ||
"info": { | ||
"cause": { | ||
"kind": "DuplicatedIdentity" | ||
} | ||
} | ||
} |
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,83 @@ | ||
{{ $userID := (uuidv4) }} | ||
{{ $identityID := (uuidv4) }} | ||
|
||
INSERT INTO | ||
_auth_user ( | ||
"id", | ||
"app_id", | ||
"created_at", | ||
"updated_at", | ||
"last_login_at", | ||
"login_at", | ||
"is_disabled", | ||
"disable_reason", | ||
"standard_attributes", | ||
"custom_attributes", | ||
"is_deactivated", | ||
"delete_at", | ||
"is_anonymized", | ||
"anonymize_at", | ||
"anonymized_at", | ||
"last_indexed_at", | ||
"require_reindex_after" | ||
) | ||
VALUES | ||
( | ||
'{{ $userID }}', | ||
'{{ .AppID }}', | ||
NOW(), | ||
NOW(), | ||
NULL, | ||
NOW(), | ||
'f', | ||
NULL, | ||
'{"email": "[email protected]"}', | ||
'{}', | ||
'f', | ||
NULL, | ||
'f', | ||
NULL, | ||
NULL, | ||
NOW(), | ||
NOW() | ||
); | ||
|
||
INSERT INTO | ||
_auth_identity ( | ||
"id", | ||
"app_id", | ||
"type", | ||
"user_id", | ||
"created_at", | ||
"updated_at" | ||
) | ||
VALUES | ||
( | ||
'{{ $identityID }}', | ||
'{{ .AppID }}', | ||
'ldap', | ||
'{{ $userID }}', | ||
NOW(), | ||
NOW() | ||
); | ||
|
||
INSERT INTO | ||
_auth_identity_ldap ( | ||
"id", | ||
"app_id", | ||
"server_name", | ||
"user_id_attribute_name", | ||
"user_id_attribute_value", | ||
"claims", | ||
"raw_entry_json" | ||
) | ||
VALUES | ||
( | ||
'{{ $identityID }}', | ||
'{{ .AppID }}', | ||
'ldap-server-1', | ||
'uid', | ||
'mock', | ||
'{"email": "[email protected]"}', | ||
'{"dn": "cn=mock,ou=people,ou=HK,dc=authgear,dc=com"}' | ||
); |
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 |
---|---|---|
|
@@ -79,5 +79,5 @@ VALUES | |
'uid', | ||
'jdoe', | ||
'{"email": "[email protected]"}', | ||
'{"dn": "cn=jdoe,ou=people,ou=HK,dc=authgear,dc=com", "uid": "jdoe", "mail": "[email protected]"}' | ||
'{"dn": "cn=jdoe,ou=people,ou=HK,dc=authgear,dc=com"}' | ||
); |
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
Oops, something went wrong.