Skip to content

Commit

Permalink
Revert embedded link (#262)
Browse files Browse the repository at this point in the history
* Revert "Generate an embedded token for user (#260)"

This reverts commit 9b99ac8.

* Block embedded link for now
  • Loading branch information
aviadl committed Jul 31, 2023
1 parent 25833aa commit b544883
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 61 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
"python.testing.pytestArgs": [
"tests"
],
"workbench.colorCustomizations": {
"activityBar.background": "#4D1C3B",
"titleBar.activeBackground": "#6B2752",
"titleBar.activeForeground": "#FDF8FB"
},
}
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -852,10 +852,6 @@ pending_ref = resp["pendingRef"]

# Note 1: The generate code/link functions, work only for test users, will not work for regular users.
# Note 2: In case of testing sign-in / sign-up operations with test users, need to make sure to generate the code prior calling the sign-in / sign-up operations.

# Embedded links can be created to directly receive a verifiable token without sending it.
# This token can then be verified using the magic link 'verify' function, either directly or through a flow.
token, err = descope_client.mgmt.user.generate_embedded_link("[email protected]", {"key1":"value1"})
```

## API Rate Limits
Expand Down
1 change: 0 additions & 1 deletion descope/management/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class MgmtV1:
user_generate_otp_for_test_path = "/v1/mgmt/tests/generate/otp"
user_generate_magic_link_for_test_path = "/v1/mgmt/tests/generate/magiclink"
user_generate_enchanted_link_for_test_path = "/v1/mgmt/tests/generate/enchantedlink"
user_generate_embedded_link_path = "/v1/mgmt/user/signin/embeddedlink"

# access key
access_key_create_path = "/v1/mgmt/accesskey/create"
Expand Down
22 changes: 0 additions & 22 deletions descope/management/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,28 +923,6 @@ def generate_enchanted_link_for_test_user(
)
return response.json()

def generate_embedded_link(self, login_id: str, custom_claims: dict = None) -> str:
"""
Generate Embedded Link for the given user login ID.
The return value is a token that can be verified via magic link, or using flows
Args:
login_id (str): The login ID of the user to authenticate with.
custom_claims (dict): Additional claims to place on the jwt after verification
Return value (str):
Return the token to be used in verification process
Raise:
AuthException: raised if the operation fails
"""
response = self._auth.do_post(
MgmtV1.user_generate_embedded_link_path,
{"loginId": login_id, "customClaims": custom_claims},
pswd=self._auth.management_key,
)
return response.json()["token"]

@staticmethod
def _compose_create_body(
login_id: str,
Expand Down
34 changes: 0 additions & 34 deletions tests/management/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,37 +1230,3 @@ def test_generate_enchanted_link_for_test_user(self):
verify=True,
timeout=DEFAULT_TIMEOUT_SECONDS,
)

def test_generate_embedded_link(self):
# Test failed flows
with patch("requests.post") as mock_post:
mock_post.return_value.ok = False
self.assertRaises(
AuthException, self.client.mgmt.user.generate_embedded_link, "login-id"
)

# Test success flow
with patch("requests.post") as mock_post:
network_resp = mock.Mock()
network_resp.ok = True
network_resp.json.return_value = json.loads("""{"token": "some-token"}""")
mock_post.return_value = network_resp
resp = self.client.mgmt.user.generate_embedded_link(
"login-id", {"k1": "v1"}
)
self.assertEqual(resp, "some-token")
mock_post.assert_called_with(
f"{common.DEFAULT_BASE_URL}{MgmtV1.user_generate_embedded_link_path}",
headers={
**common.default_headers,
"Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}",
},
json={
"loginId": "login-id",
"customClaims": {"k1": "v1"},
},
allow_redirects=False,
verify=True,
params=None,
timeout=DEFAULT_TIMEOUT_SECONDS,
)

0 comments on commit b544883

Please sign in to comment.