Skip to content

Commit a2c0d8c

Browse files
committed
Merge branch 'master' into support_hashicorp_vault
2 parents 66ddc5b + 3919e26 commit a2c0d8c

File tree

6 files changed

+24
-14
lines changed

6 files changed

+24
-14
lines changed

blessclient.cfg.sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ update_script: update_blessclient.sh
6262
# tokens for when the user assumes the role necessary to call the BLESS Lambda. The default
6363
# is 3600 seconds (1 hour). The value must be in the range 900-3600.
6464

65+
# update_sshagent: Specifies whether the identity key should be automatically added to the
66+
running ssh-agent. If this option is set to 'true', the key and the ssh certificate retrieved
67+
from lambda are added to the agent. If this option is set to 'false', the key is not added
68+
to the agent. The default is 'true'.
69+
6570
[LAMBDA]
6671
# user_role: IAM Role that the user will assume, in order to run the BLESS Lambda. This
6772
# role should be in the same AWS account as your Lambda.

blessclient/bless_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class BlessConfig(object):
77
DEFAULT_CONFIG = {
88
'user_session_length': '64800',
99
'usebless_role_session_length': '3600',
10+
'update_sshagent': 'true',
1011
'remote_user': None,
1112
}
1213

@@ -39,6 +40,7 @@ def parse_config_file(self, config_file):
3940
'update_script': config.get('CLIENT', 'update_script'),
4041
'user_session_length': int(config.get('CLIENT', 'user_session_length')),
4142
'usebless_role_session_length': int(config.get('CLIENT', 'usebless_role_session_length')),
43+
'update_sshagent': config.getboolean('CLIENT', 'update_sshagent'),
4244
},
4345
'BLESS_CONFIG': {
4446
'ca_backend': config.get('MAIN', 'ca_backend'),

blessclient/client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,18 @@ def bless(region, nocache, showgui, hostname, bless_config):
793793
raise LambdaInvocationException(
794794
'BLESS client did not recieve a valid cert. Instead got: {}'.format(cert))
795795

796+
# Remove RSA identity from ssh-agent (if it exists)
796797
ssh_agent_remove_bless(identity_file)
797798
with open(cert_file, 'w') as cert_file:
798799
cert_file.write(cert)
799-
ssh_agent_add_bless(identity_file)
800+
801+
# Check if we can skip adding identity into the running ssh-agent
802+
if bless_config.get_client_config()['update_sshagent'] is True:
803+
ssh_agent_add_bless(identity_file)
804+
else:
805+
logging.info(
806+
"Skipping loading identity into the running ssh-agent "
807+
'because this was disabled in the blessclient config.' )
800808

801809
bless_cache.set('certip', my_ip)
802810
bless_cache.save()

blessclient/tokengui.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,10 @@ def doGUI(self, hostname=None):
3232
self.master.attributes('-topmost', True)
3333
self.master.focus_force()
3434
self.e1.focus_set()
35+
3536
if platform.system() == 'Darwin':
36-
try:
37-
from Cocoa import (
38-
NSRunningApplication,
39-
NSApplicationActivateIgnoringOtherApps
40-
)
41-
42-
app = NSRunningApplication.runningApplicationWithProcessIdentifier_(
43-
os.getpid()
44-
)
45-
app.activateWithOptions_(NSApplicationActivateIgnoringOtherApps)
46-
except ImportError:
47-
pass
37+
# Hack to get the GUI dialog focused in OSX
38+
os.system('/usr/bin/osascript -e \'tell app "Finder" to set frontmost of process "python" to true\'')
4839

4940
mainloop()
5041

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="blessclient",
5-
version="0.2.0",
5+
version="0.3.0",
66
packages=find_packages(exclude=["test*"]),
77
install_requires=[
88
'boto3>=1.4.0,<2.0.0',

tests/blessclient/bless_config_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ip_urls: http://checkip.amazonaws.com, http://api.ipify.org
2323
update_script: autoupdate.sh
2424
user_session_length: 3600
25+
update_sshagent: false
2526
2627
[LAMBDA]
2728
user_role: use-bless
@@ -121,6 +122,7 @@ def test_load_config():
121122
'update_script': 'autoupdate.sh',
122123
'user_session_length': 3600,
123124
'usebless_role_session_length': 3600, # comes from BlessConfig.DEFAULT_CONFIG
125+
'update_sshagent': False
124126
},
125127
'VAULT_CONFIG': {
126128
'vault_addr': 'https://vault.example.com:1234',
@@ -140,6 +142,8 @@ def test_get_region_alias_from_aws_region(bless_config_test):
140142
def test_get_configs(bless_config_test):
141143
client_config = bless_config_test.get_client_config()
142144
assert 'domain_regex' in client_config
145+
assert bool(client_config['update_sshagent']) is False
146+
assert type(client_config['update_sshagent']).__name__ == 'bool'
143147
lambda_config = bless_config_test.get_lambda_config()
144148
assert 'functionname' in lambda_config
145149
aws_config = bless_config_test.get_aws_config()

0 commit comments

Comments
 (0)