pyntcli 0.1.112__py3-none-any.whl → 0.1.113__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ignoreTests/auth/login.py CHANGED
@@ -59,7 +59,7 @@ class TestLogin():
59
59
  with pytest.raises(Timeout):
60
60
  with requests_mock.mock() as m:
61
61
  m.add_matcher(self.poll_matcher)
62
- l.get_token_using_request_id("some_id")
62
+ l.claim_token_using_device_code("some_id")
63
63
 
64
64
  def test_is_jwt_expired(self):
65
65
 
pyntcli/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.112"
1
+ __version__ = "0.1.113"
pyntcli/auth/login.py CHANGED
@@ -1,6 +1,7 @@
1
+ import random
2
+ import string
1
3
  from base64 import b64decode
2
4
  import webbrowser
3
- import uuid
4
5
  import urllib.parse
5
6
  import datetime
6
7
  import time
@@ -28,6 +29,8 @@ PYNT_ID = "PYNT_ID"
28
29
  PYNT_CREDENTIALS = "PYNT_CREDENTIALS"
29
30
  PYNT_SAAS = os.environ.get("PYNT_SAAS_URL") if os.environ.get(
30
31
  "PYNT_SAAS_URL") else "https://api.pynt.io/v1"
32
+ PYNT_APP_URL = os.environ.get("PYNT_APP_URL") if os.environ.get(
33
+ "PYNT_APP_URL") else "https://app.pynt.io"
31
34
  PYNT_BUCKET_NAME = os.environ.get(
32
35
  "PYNT_BUCKET_NAME") if os.environ.get("PYNT_BUCKET_NAME") else ""
33
36
  PYNT_PARAM1 = os.environ.get(
@@ -36,18 +39,24 @@ PYNT_PARAM2 = os.environ.get(
36
39
  "PYNT_PARAM2") if os.environ.get("PYNT_PARAM2") else ""
37
40
 
38
41
 
42
+ def generate_device_code() -> str:
43
+ """
44
+ Generates a random 8 alphanumeric string of pattern `XXXX-XXXX`
45
+ """
46
+ part_one = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(4))
47
+ part_two = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(4))
48
+ return f"{part_one}-{part_two}"
49
+
50
+
39
51
  class Login():
40
52
  def __init__(self) -> None:
41
53
  self.delay = 5
42
- self.base_authorization_url = "https://pynt.io/login?"
43
- self.poll_url = "https://n592meacjj.execute-api.us-east-1.amazonaws.com/default/cli_validate_login"
44
54
  self.login_wait_period = (60 * 3) # 3 minutes
45
55
 
46
- def create_login_request(self):
47
- request_id = uuid.uuid4()
48
- request_url = self.base_authorization_url + \
49
- urllib.parse.urlencode(
50
- {"request_id": request_id, "utm_source": "cli"})
56
+ def create_login_request(self) -> str:
57
+ device_code = generate_device_code()
58
+ request_url = f"{PYNT_APP_URL}/login?" + urllib.parse.urlencode(
59
+ {"device_code": device_code, "utm_source": "cli"})
51
60
  webbrowser.open(request_url)
52
61
 
53
62
  ui_thread.print(ui_thread.PrinterText("To continue, you need to log in to your account.")
@@ -55,22 +64,22 @@ class Login():
55
64
  .with_line("")
56
65
  .with_line("If you are not automatically redirected, please click on the link provided below (or copy to your web browser)")
57
66
  .with_line(request_url))
58
- return request_id
67
+ return device_code
59
68
 
60
- def get_token_using_request_id(self, request_id):
69
+ def claim_token_using_device_code(self, device_code: str):
70
+ poll_url = f"{PYNT_SAAS}/auth/device-code/{device_code}"
61
71
  with ui_thread.spinner("Waiting...", "point"):
62
72
  start = time.time()
63
73
  while start + self.login_wait_period > time.time():
64
- response = pynt_requests.get(self.poll_url, params={
65
- "request_id": request_id})
74
+ response = pynt_requests.get(poll_url)
66
75
  if response.status_code == 200:
67
76
  return response.json()
68
77
  time.sleep(self.delay)
69
78
  raise Timeout()
70
79
 
71
80
  def login(self):
72
- id = self.create_login_request()
73
- token = self.get_token_using_request_id(id)
81
+ device_code = self.create_login_request()
82
+ token = self.claim_token_using_device_code(device_code)
74
83
  with CredStore() as store:
75
84
  store.put("token", token)
76
85
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pyntcli
3
- Version: 0.1.112
3
+ Version: 0.1.113
4
4
  Summary: Command line utility to handle all of Pynt's different integrations
5
5
  Author-email: Pynt-io <support@pynt.io>
6
6
  Project-URL: Homepage, https://pynt.io
@@ -1,12 +1,12 @@
1
1
  ignoreTests/conftest.py,sha256=gToq5K74GtgeGQXjFvXSzMaE6axBYxAzcFG5XJPOXjI,427
2
- ignoreTests/auth/login.py,sha256=KFlzWhXBAuwdi7GXf16gCB3ya94LQG2wjcSChE149rQ,3798
2
+ ignoreTests/auth/login.py,sha256=7GeBirHTD9t6EassLYsegCw1FZHkfjvVW1Z5uybHzgM,3801
3
3
  ignoreTests/store/cred_store.py,sha256=_7-917EtNC9eKEumO2_lt-7KuDmCwOZFaowCm7DbA_A,254
4
- pyntcli/__init__.py,sha256=NcX8fgfLWWXa9SmAPHplHcOIvbX0m3-mYipZHIVAlvg,24
4
+ pyntcli/__init__.py,sha256=j3sjtalrZ7qzajUh_46Une0yUZprSFiTpVECCQnsaGI,24
5
5
  pyntcli/main.py,sha256=RD0W2_0ogYBCXubo-YewxHYkiIXxNv6NkZOh3n1VujE,5964
6
6
  pyntcli/analytics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  pyntcli/analytics/send.py,sha256=0hJ0WJNFHLqyohtRr_xOg5WEXzxHrUOlcePPg-k65Hk,3846
8
8
  pyntcli/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- pyntcli/auth/login.py,sha256=dnjDT4_3RLzOT3zknUic3iRYHS8D6y00xWwNoaxOL2U,5524
9
+ pyntcli/auth/login.py,sha256=Oz1DtEZje0afgJcHSwEFHcH78X-QD5Mjn0CQ9ZgCfQU,5844
10
10
  pyntcli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  pyntcli/commands/burp.py,sha256=AUJU2cIJ-PSUATxYoHRwDy0K5feqCs-mGdkGle2WcDw,14173
12
12
  pyntcli/commands/command.py,sha256=3egvDDr68sTUnyJpUE0bO9TfVy_rgeuM2C4zkMA-9GQ,10903
@@ -40,8 +40,8 @@ pyntcli/ui/report.py,sha256=W-icPSZrGLOubXgam0LpOvHLl_aZg9Zx9qIkL8Ym5PE,1930
40
40
  pyntcli/ui/ui_thread.py,sha256=XUBgLpYQjVhrilU-ofw7VSXgTiwneSdTxm61EvC3x4Q,5091
41
41
  tests/test_utils.py,sha256=t5fTQUk1U_Js6iMxcGYGqt4C-crzOJ0CqCKtLkRtUi0,2050
42
42
  tests/commands/test_pynt_cmd.py,sha256=BjGFCFACcSziLrNA6_27t6TjSmvdu54wx9njwLpRSJY,8379
43
- pyntcli-0.1.112.dist-info/METADATA,sha256=f4PXxcRTkaLVSvJiaGUickD5MC1-8MNtmVF8YFbOVXE,427
44
- pyntcli-0.1.112.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
45
- pyntcli-0.1.112.dist-info/entry_points.txt,sha256=kcGmqAxXDttNk2EPRcqunc_LTVp61gzakz0v-GEE2SY,43
46
- pyntcli-0.1.112.dist-info/top_level.txt,sha256=64XSgBzSpgwjYjEKHZE7q3JH2a816zEeyZBXfJi3AKI,42
47
- pyntcli-0.1.112.dist-info/RECORD,,
43
+ pyntcli-0.1.113.dist-info/METADATA,sha256=8sdhJod-t85esbW4yJ0okltq4ljGEX1_4sQ2u5p5Mhg,427
44
+ pyntcli-0.1.113.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
45
+ pyntcli-0.1.113.dist-info/entry_points.txt,sha256=kcGmqAxXDttNk2EPRcqunc_LTVp61gzakz0v-GEE2SY,43
46
+ pyntcli-0.1.113.dist-info/top_level.txt,sha256=64XSgBzSpgwjYjEKHZE7q3JH2a816zEeyZBXfJi3AKI,42
47
+ pyntcli-0.1.113.dist-info/RECORD,,