Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update security examples

some typos, fix handling of whitelist/blacklist
  • Loading branch information...
commit 1c7d4ac0f998abcab2a411118e0d269f71eaa71f 1 parent a097c57
Min RK minrk authored
0  examples/security/generate_keys.py → examples/security/generate_certificates.py
View
File renamed without changes
2  examples/security/ioloop-ironhouse.py
View
@@ -74,7 +74,7 @@ def setup_client(client_secret_file, server_public_file, endpoint='tcp://127.0.0
def run():
'''Run Ironhouse example'''
- # These direcotries are generated by the generate_keys script
+ # These direcotries are generated by the generate_certificates script
base_dir = os.path.dirname(__file__)
keys_dir = os.path.join(base_dir, 'certificates')
public_keys_dir = os.path.join(base_dir, 'public_keys')
4 examples/security/ironhouse.py
View
@@ -23,14 +23,14 @@
def run():
''' Run Ironhouse example '''
- # These direcotries are generated by the generate_keys script
+ # These direcotries are generated by the generate_certificates script
base_dir = os.path.dirname(__file__)
keys_dir = os.path.join(base_dir, 'certificates')
public_keys_dir = os.path.join(base_dir, 'public_keys')
secret_keys_dir = os.path.join(base_dir, 'private_keys')
if not (os.path.exists(keys_dir) and os.path.exists(keys_dir) and os.path.exists(keys_dir)):
- logging.critical("Certificates are missing - run generate_certificates script first")
+ logging.critical("Certificates are missing - run generate_certificates.py script first")
sys.exit(1)
ctx = zmq.Context().instance()
4 examples/security/stonehouse.py
View
@@ -24,14 +24,14 @@
def run():
''' Run Stonehouse example '''
- # These directories are generated by the generate_keys script
+ # These directories are generated by the generate_certificates script
base_dir = os.path.dirname(__file__)
keys_dir = os.path.join(base_dir, 'certificates')
public_keys_dir = os.path.join(base_dir, 'public_keys')
secret_keys_dir = os.path.join(base_dir, 'private_keys')
if not (os.path.exists(keys_dir) and os.path.exists(keys_dir) and os.path.exists(keys_dir)):
- logging.critical("Certificates are missing: run generate_keys.py script first")
+ logging.critical("Certificates are missing: run generate_certificates.py script first")
sys.exit(1)
ctx = zmq.Context().instance()
22 examples/security/strawhouse.py
View
@@ -46,23 +46,27 @@ def run():
msg = client_allow.recv()
if msg == b"Hello":
allow_test_pass = True
- else:
- allow_test_pass = False
client_allow.close()
# Part 2 - demonstrate denying clients based on IP address
+ auth.stop()
+
+ auth = ThreadAuthenticator(ctx)
+ auth.start()
+
auth.deny('127.0.0.1')
- server.send(b"Hello")
-
client_deny = ctx.socket(zmq.PULL)
client_deny.connect('tcp://127.0.0.1:9000')
-
- if client_deny.poll(50):
- msg = client_deny.recv()
- if msg == b"Hello":
- deny_test_pass = False
+
+ if server.poll(50, zmq.POLLOUT):
+ server.send(b"Hello")
+
+ if client_deny.poll(50):
+ msg = client_deny.recv()
+ else:
+ deny_test_pass = True
else:
deny_test_pass = True
Please sign in to comment.
Something went wrong with that request. Please try again.