Skip to content

Commit 7dde88f

Browse files
committed
version bump and no ssl verify logic
1 parent 5a8ecfe commit 7dde88f

4 files changed

Lines changed: 40 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
All changes to the package starting with v0.3.1 will be logged here.
44

5+
## v0.7.2 [2022-12-12]
6+
#### What's New
7+
* None
8+
9+
#### Enhancements
10+
* None
11+
12+
#### Bug Fixes
13+
* None
14+
15+
#### Dependencies
16+
* `britive~=2.12.3` from `britive~=2.12.2` - AWS provider tenant port removal, disable SSL verification, json decode bug fix
17+
18+
#### Other
19+
* None
20+
521
## v0.7.1 [2022-11-28]
622
#### What's New
723
* None

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
britive~=2.12.2
1+
britive~=2.12.3
22
certifi==2022.6.15
33
charset-normalizer==2.1.0
44
click==8.1.3

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pybritive
3-
version = 0.7.1
3+
version = 0.7.2
44
author = Britive Inc.
55
author_email = support@britive.com
66
description = A pure Python CLI for Britive
@@ -26,7 +26,7 @@ install_requires =
2626
toml
2727
cryptography
2828
python-dateutil
29-
britive>=2.12.2
29+
britive>=2.12.3
3030

3131
[options.packages.find]
3232
where = src

src/pybritive/helpers/credentials.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import time
55
import webbrowser
66
import requests
7+
from requests.adapters import HTTPAdapter, Retry
78
from pathlib import Path
89
import click
910
import configparser
@@ -50,6 +51,7 @@ def __init__(self, tenant_name: str, tenant_alias: str, cli: any, federation_pro
5051
self.alias = tenant_alias
5152
self.base_url = f'https://{Britive.parse_tenant(tenant_name)}'
5253
self.federation_provider = federation_provider
54+
self.session = None
5355

5456
# not sure if we really need 32 random bytes or if any random string would work
5557
# but the current britive-cli in node.js does it this way so it will be done the same
@@ -58,10 +60,29 @@ def __init__(self, tenant_name: str, tenant_alias: str, cli: any, federation_pro
5860
self.auth_token = b64_encode_url_safe(bytes(hashlib.sha512(self.verifier.encode('utf-8')).digest()))
5961
self.credentials = self.load() or {}
6062

63+
def _setup_requests_session(self):
64+
self.session = requests.Session()
65+
retries = Retry(total=5, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504])
66+
self.session.mount('https://', HTTPAdapter(max_retries=retries))
67+
68+
# allow the disabling of TLS/SSL verification for testing in development (mostly local development)
69+
if os.getenv('BRITIVE_NO_VERIFY_SSL') and '.dev.' in self.tenant:
70+
# turn off ssl verification
71+
self.session.verify = False
72+
# wipe these due to this bug: https://github.com/psf/requests/issues/3829
73+
os.environ['CURL_CA_BUNDLE'] = ""
74+
os.environ['REQUESTS_CA_BUNDLE'] = ""
75+
# disable the warning message
76+
import urllib3
77+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
78+
6179
def perform_interactive_login(self):
6280
self.cli.print(f'Performing interactive login against tenant {self.tenant}.')
6381
url = f'{self.base_url}/login?token={self.auth_token}'
6482

83+
# establish a requests session which will be used in retrieve_tokens()
84+
self._setup_requests_session()
85+
6586
try:
6687
webbrowser.get()
6788
webbrowser.open(url)

0 commit comments

Comments
 (0)