Skip to content

Commit bd4f879

Browse files
authored
Merge pull request lyft#9 from lyft/SEC-1362-env-ip-override
[SEC-1362] Allow user to set their cert IP instead of detecting
2 parents 619550c + 97ad46b commit bd4f879

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

blessclient/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,8 @@ def bless(region, nocache, showgui, hostname, bless_config):
447447
userIP = UserIP(
448448
bless_cache=bless_cache,
449449
maxcachetime=bless_lambda_config['ipcachelifetime'],
450-
ip_urls=bless_config.get_client_config()['ip_urls'])
450+
ip_urls=bless_config.get_client_config()['ip_urls'],
451+
fixed_ip=os.getenv('BLESSFIXEDIP', False))
451452

452453
# Check if we can skip asking for MFA code
453454
if nocache is not True:

blessclient/user_ip.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66

77
class UserIP(object):
88

9-
def __init__(self, bless_cache, maxcachetime, ip_urls):
9+
def __init__(self, bless_cache, maxcachetime, ip_urls, fixed_ip=False):
1010
self.fresh = False
1111
self.currentIP = None
1212
self.cache = bless_cache
1313
self.maxcachetime = maxcachetime
1414
self.ip_urls = ip_urls
15+
if fixed_ip:
16+
self.currentIP = fixed_ip
17+
self.fresh = True
1518

1619
def getIP(self):
1720
if self.fresh and self.currentIP:

tests/blessclient/user_ip_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ def test_getIP_fresh():
1212
assert user_ip.getIP() == '1.1.1.1'
1313

1414

15+
def test_fixed_ip():
16+
user_ip = UserIP(None, 10, IP_URLS, '1.2.3.4')
17+
assert user_ip.getIP() == '1.2.3.4'
18+
19+
1520
def test_getIP_cached():
1621
bc = BlessCache(None, None, BlessCache.CACHEMODE_ENABLED)
1722
bc.cache = {}

0 commit comments

Comments
 (0)