Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
43d4c08
Fix shebang, always resolve path to full absolute path.
Kami Jun 5, 2018
3df2e6d
Add cryptography dependency.
Kami Jun 5, 2018
9c2a075
Add new implementation of symetric_encrypt and symetric_decrypt
Kami Jun 5, 2018
dcd778e
Update st2-generate-symmetric-crypto-key utilitu to use cryptography
Kami Jun 5, 2018
9c58713
Add back symmetric_encrypt and symmetric_decrypt alias functions.
Kami Jun 5, 2018
060e997
Update affected tests.
Kami Jun 5, 2018
554725b
Add tests which verify symmetric_encrypt and symmetric_decrypt functions
Kami Jun 5, 2018
1526530
Add tests for keyczar compatible key file generation.
Kami Jun 5, 2018
f4caf64
Add more tests, skip keyczar tests under Python 3.
Kami Jun 5, 2018
d56f467
Add keyczar test key fixtures.
Kami Jun 5, 2018
4a75060
Throw on invalid mode and unsafe key size.
Kami Jun 6, 2018
6e7934d
Add tests for loading keys from keyczar compatible key files.
Kami Jun 6, 2018
e5645a3
Also add test case for loading 128 bit aes keys.
Kami Jun 6, 2018
9bf6041
Keyczar is now only a test dependency, re-generate requirements.txt
Kami Jun 6, 2018
bf02406
Update help string.
Kami Jun 6, 2018
3f44c1a
Various Python 3 compatibility fixes.
Kami Jun 6, 2018
bae269a
Run more tests under Python 3.
Kami Jun 6, 2018
d894bee
Rephrase docstring.
Kami Jun 7, 2018
70f63c4
Improve docstrings, add additional asserts, use consistent variable
Kami Jun 7, 2018
9be8ed8
Add more tests.
Kami Jun 7, 2018
d1ba3b8
Fix lint.
Kami Jun 7, 2018
60426cf
Merge branch 'master' of github.com:StackStorm/st2 into move_from_key…
Kami Jun 8, 2018
8f20eed
Add a comment on why that requirement is there.
Kami Jun 8, 2018
5e0c29d
Merge branch 'master' into move_from_keyczar_to_cryptography_py3
Kami Jun 11, 2018
3c5c381
Fix mode check.
Kami Jun 12, 2018
16a080b
Rename __json__() method to to_json().
Kami Jun 12, 2018
fe48f38
Update invalid docstring.
Kami Jun 12, 2018
9e9ce8b
Use a constant for minimum AES key size.
Kami Jun 12, 2018
6259ef4
Add tests for AESKey class constructor.
Kami Jun 12, 2018
5955e5c
Merge branch 'master' into move_from_keyczar_to_cryptography_py3
Kami Jun 12, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conf/st2.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ action_executions_output_ttl = 7
collection_interval = 600

[keyvalue]
# Location of the symmetric encryption key for encrypting values in kvstore. This key should be in JSON and should've been generated using keyczar.
# Location of the symmetric encryption key for encrypting values in kvstore. This key should be in JSON and should've been generated using st2-generate-symmetric-crypto-key tool.
encryption_key_path =
# Allow encryption of values in key value stored qualified as "secret".
enable_encryption = True
Expand Down
2 changes: 0 additions & 2 deletions contrib/runners/python_runner/tests/unit/test_pythonrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import six
import mock
import unittest2
from oslo_config import cfg

from python_runner import python_runner
Expand Down Expand Up @@ -200,7 +199,6 @@ def test_simple_action_no_status_backward_compatibility(self):
self.assertTrue(output is not None)
self.assertEqual(output['result'], [1, 2])

@unittest2.skipIf(six.PY3, 'keyczar doesn\'t work under Python 3')
def test_simple_action_config_value_provided_overriden_in_datastore(self):
pack = 'dummy_pack_5'
user = 'joe'
Expand Down
1 change: 1 addition & 0 deletions fixed-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ stevedore==1.28.0
paramiko==2.4.1
networkx==1.11
python-keyczar==0.716
cryptography==2.2.2
retrying==1.3.3
# Note: We use latest version of virtualenv which uses pip 9.0
virtualenv==15.1.0
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ RandomWords
apscheduler==3.5.1
argcomplete
bcrypt
cryptography==2.2.2
eventlet==0.23.0
flex==6.13.1
git+https://github.com/Kami/logshipper.git@stackstorm_patched#egg=logshipper
Expand Down Expand Up @@ -37,7 +38,6 @@ python-dateutil
python-editor==1.0.3
python-gnupg==0.4.2
python-json-logger
python-keyczar==0.716
python-statsd==2.1.0
pytz==2018.4
pyyaml<4.0,>=3.12
Expand Down
27 changes: 23 additions & 4 deletions st2common/bin/st2-generate-symmetric-crypto-key
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


import argparse
import os
import sys

from keyczar.keys import AesKey
from st2common.util.crypto import AESKey


def main(key_path, force=False):
key_path = os.path.abspath(key_path)
base_path = os.path.dirname(key_path)

if not os.access(base_path, os.W_OK):
print('ERROR: You do not have sufficient permissions to write to path: %s.' % key_path)
print('Try setting up permissions correctly and then run this tool.')
Expand All @@ -23,9 +40,11 @@ def main(key_path, force=False):

print('WARNING: Rewriting existing key with new key!')

# Explicitly chose large key size
aes_key = AESKey.generate(key_size=256)

with open(key_path, 'w') as key_file:
k = AesKey.Generate()
key_file.write(str(k))
key_file.write(aes_key.to_json())
key_file.flush()

msg = ('Key written to %s. ' % key_path + 'Secure the permissions so only StackStorm API ' +
Expand Down
2 changes: 1 addition & 1 deletion st2common/in-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ oslo.config
paramiko
pyyaml
pymongo
python-keyczar
cryptography
requests
retrying
semver
Expand Down
2 changes: 1 addition & 1 deletion st2common/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Don't edit this file. It's generated automatically!
apscheduler==3.5.1
cryptography==2.2.2
eventlet==0.23.0
flex==6.13.1
greenlet==0.4.13
Expand All @@ -15,7 +16,6 @@ paramiko==2.4.1
prometheus_client==0.1.1
pymongo==3.6.1
python-dateutil
python-keyczar==0.716
python-statsd==2.1.0
pyyaml<4.0,>=3.12
requests[security]<2.15,>=2.14.1
Expand Down
3 changes: 2 additions & 1 deletion st2common/st2common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ def register_opts(ignore_errors=False):
cfg.StrOpt(
'encryption_key_path', default='',
help='Location of the symmetric encryption key for encrypting values in kvstore. '
'This key should be in JSON and should\'ve been generated using keyczar.')
'This key should be in JSON and should\'ve been generated using '
'st2-generate-symmetric-crypto-key tool.')
]

do_register_opts(keyvalue_opts, group='keyvalue')
Expand Down
Loading