Commit Graph

176 Commits

Author SHA1 Message Date
Peter Hamilton 8abe3de8cb Remove invalid escape sequences
A recent style update to Python 3.6 adds deprecation W605, which
tightens the usage of invalid escape sequences. This patch removes
any instances of invalid escape sequences from the PyKMIP code
base, bringing the library back up to compliance with Python style.
2018-11-15 13:53:06 -05:00
Peter Hamilton 0819574424
Merge pull request #458 from tipabu/eoferror-text
Change EOFError text
2018-10-10 08:51:40 -04:00
Tim Burke f60bae83d0 Secure logging by default
As an application developer, you might expect to be able to turn on
debug logging at the root logger with something like

    logging.basicConfig(level=logging.DEBUG)

However, if the application needed to fetch any secrets from a KMIP
server, these previously would be logged as part of the wire protocol.
Further, any passwords in configs would also get logged at DEBUG.
Applications would need to proactively silence such logging, as in
https://github.com/openstack/swift/commit/12b6d46

Now, we will default the logger level to INFO to suppress the debug
logging. However, seeing the on-wire data may still be useful, for
example when developing a new KMIP server. So, allow developers to
consciously set the logger level to DEBUG.
2018-10-09 14:24:22 -07:00
Tim Burke 8e82438f25 Change EOFError text
The old text made perfect sense when in a server context, trying to
read requests from clients, but KMIPProtocol is also used by *clients*
to read *responses*. Let's change it to something a little more
request/response agnostic.
2018-10-09 14:05:55 -07:00
Peter Hamilton 9fc9c62887
Merge pull request #447 from tipabu/bug-381
Clean up KMIPProxy initialization and destruction
2018-06-28 11:24:45 -04:00
Tim Burke d291c50bd6 Clean up KMIPProxy initialization and destruction
Fixes #381.
2018-06-22 12:26:48 -07:00
Tim Burke 8bf7592db9 Preserve the stack when re-raising connection errors 2018-06-22 12:11:16 -07:00
Tim Burke 6306846b45 Log connection error details per-host
Otherwise, you don't get much insight into why you had to settle for
your third configured host. Now, you can get information like

   An error occurred while connecting to appliance foo.bar:
      [Errno -5] No address associated with hostname
   An error occurred while connecting to appliance localhost:
      [Errno 111] Connection refused

even when we ultimately succeed in creating a client.
2018-06-22 12:11:16 -07:00
Peter Hamilton b878dbfdf9
Merge pull request #438 from OpenKMIP/feat/update-access-denied-error
Raise PermissionDenied on access control violations
2018-05-17 15:55:16 -04:00
Peter Hamilton 8b99c74d0b Raise PermissionDenied on access control violations
This change changes the error the server uses when access control
violations occur, specifically swapping from the more agnostic
ItemNotFound to the more explicit PermissionDenied. This change
better conforms with the expected behavior of a KMIP server.
2018-05-17 14:23:07 -04:00
Peter Hamilton 008f86cfa9 Rename the 'default' policy section to 'preset'
This change tweaks the format of operation policy files, renaming
the 'default' section of each policy to 'preset'. This reinforces
the idea that this section of the policy is used only when group-
based access control is disabled. It also removes any ambiguity
between this section of the policy and the actual 'default'
policy built into the server.
2018-05-17 13:55:50 -04:00
Peter Hamilton 3a7b880bdf Fix a denial-of-service bug by setting the server socket timeout
This change fixes a potential denial-of-service bug with the
server, setting a default timeout for all server sockets. This
allows the server to drop hung connections without blocking
forever. The interrupt triggered during accept calls is expected
and is now handled appropriately. Server unit tests have been
updated to reflect this change.

Closes #430
2018-04-24 21:57:20 -04:00
Peter Hamilton f9e32552f8 Add client support for custom configuration file paths
This change adds client support for setting custom configuration
file paths, allowing users and developers to place their settings
file wherever they want. All client demo scripts have been updated
to support a '-s' flag that can be used to set the configuration
file for the demo. Client unit tests have also been updated to
include this change.
2018-04-17 14:41:04 -04:00
Peter Hamilton 2e6384a067 Add server support for customizing the backend storage file
This change updates the server, adding in support for customizing
the backend storage file used to store all server data. The server
currently uses a simple SQLite database for storage. Prior versions
of the server kept this database file in /tmp, to emphasize the
testing focus of the server. This change loosens that restriction,
now allowing users to customize where the database file lives. A
new configuration option, 'database_path', has been added that will
override the default /tmp location for the database file. This
value can also be passed in if invoking the server via script using
the '-d' flag.
2018-04-16 14:14:10 -04:00
Peter Hamilton 66929198c3 Add Rekey support to the KMIPProxy client
This change adds Rekey operation support to the KMIPProxy client.
The client unit test suite has been updated to cover the new
additions.

Partially addresses #405
2018-04-15 16:45:53 -04:00
Peter Hamilton 05b5b8411a Integrate policy file monitoring with the server
This change updates the server, integrating policy file monitoring
and restructuring the engine. The top-level server entity now
handles loading policy files using the PolicyDirectoryMonitor
subprocess. A shared memory dictionary is used to share newly
modified policy data across the session threads managed by the
server and used by the engine. The legacy policy loading code in
the engine has been removed.

Unit tests have been added and modified for both the server and
engine to verify the functionality of these modifications.
2018-04-11 13:42:44 -04:00
Peter Hamilton 055483d663 Add a policy directory monitor
This change adds a PolicyDirectoryMonitor subprocess that can be
used by the server to continuously monitor and load operation
policies from the configured operation policy directory. The
monitor tracks policy file modifications, file creation, and file
deletion, restoring legacy policies from existing policy files
should the current file backing a policy get deleted. Changes to
existing policies are detected and updated as soon as the backing
policy file is saved to disk.

An extensive unit test is included to exercise the different
operating conditions the monitor may encounter.
2018-04-10 14:32:27 -04:00
Peter Hamilton 822b889f2e Add Check support to the KMIPProxy client
This change adds Check operation support to the KMIPProxy client.
The client unit test suite has been updated to cover the new
additions.

Partially addresses #405
2018-04-06 00:02:36 -04:00
Peter Hamilton 1a093f141e Update the server session to use the auth plugin framework
This change updates how the server session handles message
processing, adding support for the new authentication plugin
framework. Session unit tests have been updated to account for
this change.
2018-03-30 09:08:39 -04:00
Peter Hamilton e215ddbe7b Update server config handling to parse auth plugin settings
This change updates server configuration handling, allowing the
server to parse and store configuration settings for authentication
plugins. Unit tests have been added to cover the new functionality.
2018-03-19 16:52:34 -04:00
Peter Hamilton 98f5ba39e3 Add an authentication plugin framework
This change adds an authentication plugin framework to be used by
the PyKMIP server. This framework will allow the server to query
third-party authentication systems for user identity information,
improving the access control model for the server. The initial
plugin provided queries an instance of the new SLUGS library.
2018-03-06 22:53:29 -05:00
Peter Hamilton fc2ff5d04c Remove legacy base class code for the original client
This change removes the legacy KMIP base class that was originally
used for the KMIPProxy client. The base class simply defined the
KMIP operation methods that the client should support. It has not
been actively used to guide client development for some time and
now just clutters up the code base. The KMIPProxy class has been
updated to remove any reference to this original base class.
2018-02-26 15:02:42 -05:00
Peter Hamilton 8d492fcda4 Update the Authentication object
This change updates the Authentication object, taking into account
the recent changes made to the Credential object hierarchy. A new
comprehensive unit test suite has been added for the Authentication
object. Usage of the object in the PyKMIP server has also been
updated to reflect these changes.
2018-02-26 10:23:25 -05:00
Peter Hamilton dd4a078cc1 Update the ProtocolVersion implementation
This change updates the implementation of the ProtocolVersion
struct, bringing it inline with the current struct style. All
uses of the struct have been updated to reflect these changes,
as have the struct unit tests.
2018-02-22 13:35:11 -05:00
Peter Hamilton 61347d80b6 Update the server to support group-based operation policies
This change updates the PyKMIP server, allowing it to process and
use group-based operation policies. The server still supports the
original operation policy file format, so no immediate difference
should be apparent to users. Future documentation changes will
explain group-based policy files and how they should be used.
2018-02-19 12:12:40 -05:00
Peter Hamilton 86d9b59d1f Fixing bug with session logging shared ciphers
This change fixes a bug with the KmipSession logging shared
ciphers used by the TLS connection. The SSLSocket only supports
shared cipher information starting with Python 3.5. Any use of
the server with older versions of Python will fail when any
connection attempts are made. This fix adds a conditional check
that skips logging shared cipher information if the SSLSocket
does not support that information.

Fixes #361
2017-11-08 10:19:04 -05:00
Peter Hamilton e77dcadf41 Fixing violations of E722 for flake8 checks
This change fixes violations of E722, the use of except without
specifying an exception type. For now the high-level Exception
class is used as a generic catchall. In the future these cases
will be updated to handle the specific exceptions expected.
2017-10-23 08:43:36 -04:00
Peter Hamilton 721e7f3717 Add a ProxyKmipClient integation test for registering wrapped keys
This change adds a ProxyKmipClient integration test that verifies
that a wrapped key can be registered with the server and can then
be retrieved, along with all of its key wrapping metadata. Minor
updates to the underlying metadata handling are included.
2017-10-04 17:35:09 -04:00
Peter Hamilton 6fa4999cc5 Updating the ProxyKmipClient to support getting wrapped keys
This change updates the ProxyKmipClient, allowing Get operation
calls to retrieve wrapped keys by providing key wrapping
specification information with the request. Unit tests have been
added and updated to reflect this change.
2017-09-30 12:14:14 -04:00
Peter Hamilton 69a7b49d32 Add a logging level configuration option
This change adds a logging level configuration option for the
server, allowing the admin to control what server activity gets
collected for logging. Unit tests have been added and updated to
cover this new configuration setting.
2017-09-27 17:41:14 -04:00
Peter Hamilton 98db0dfe73 Update how private keys are handled when signing data
This change updates how private key bytes are loaded when signing
data. The prior approach required binascii to unhexlify the byte
string. The current approach removes this requirement, matching
the rest of the library. All unit tests have been updated to
reflect this change.
2017-09-26 16:15:13 -04:00
Peter Hamilton 82a7b8a741 Update payload management
This change updates payload management, streamlining the import
process for kmip.core.messages.payloads. Now any request or
response payload is accessible by importing payloads. All code
importing and using individual payload modules has been updated
to use this new approach.
2017-09-21 13:37:55 -04:00
Peter Hamilton ee857ca4a3 Adding custom TLS cipher suite config option
This change adds a server configuration option, tls_cipher_suites,
allowing the server admin to specify a list of cipher suites to be
used when establishing TLS connections with clients. The custom
list supports both cipher suite specification and OpenSSL suite
naming conventions. The list is filtered through a KMIP-approved
set of cipher suites, and then through a set of cipher suites
suitable for the configured authentication suite. Additional debug
logging has been added to the server to provide transparency on
this process.
2017-09-20 11:40:52 -04:00
Peter Hamilton c3696a9877 Merge pull request #335 from OpenKMIP/feat/add-config-extended-key-usage
Add server config option controlling certificate client auth
2017-09-14 13:32:52 -04:00
Peter Hamilton 4c6bbae452 Add server config option controlling certificate client auth
This change adds a server configuration option to control the
enforcement of TLS certificate client authentication. Before,
client TLS certificates had to include the extended key usage
extension with the clientAuth bit set to be used as sources of
client identity. The new configuration option,
enable_tls_client_auth, allows server admins to enable/disable
this requirement. The configuration setting is optional and the
server defaults to the original enforcing behavior if it is not
set. Admins must explicitly set the option to False to disable
enforcement.
2017-09-14 13:16:24 -04:00
Peter Hamilton 5c20fe9b3e Merge pull request #330 from danetrain/feat/sign-add-client-support
Add Sign operation support to clients.
2017-09-12 12:25:00 -04:00
Peter Hamilton a60c65f191 Merge pull request #331 from alishamayor/patch-1
Add REVOKE to list of supported server ops
2017-09-12 10:14:20 -04:00
Dane 22daacf5e9 Add Sign operation to clients 2017-09-07 11:14:40 -04:00
alishamayor fa548a7ebe Add REVOKE to list of supported server ops
As defined in _process_query, the list of supported server operations is missing REVOKE.
2017-08-29 17:42:55 -07:00
Peter Hamilton 64b6177fe7 Add SignatureVerify support to the clients
This change adds SignatureVerify support to the KMIPProxy and
ProxyKmipClient clients, including unit tests to cover the new
functionality.
2017-08-29 16:41:11 -04:00
Peter Hamilton fc7224e20d Add SignatureVerify support to the server
This change adds the SignatureVerify operation to the server. Unit
tests covering the additions are included. The Query operation has
been updated to reflect this addition.
2017-08-29 16:11:26 -04:00
Peter Hamilton 48ef434922 Add signature verification support
This change adds signature verification support to the server
cryptography engine. Only RSA-based signatures are currently
supported. Unit tests have been added to verify the new
functionality.
2017-08-29 13:09:56 -04:00
Dane Fichter d48b590c35 This change adds Sign operation support to the server. 2017-08-28 12:47:23 -04:00
Dane df06aa8ad8 Add engine support for sign operation
This change adds the sign operation functionality
to the cryptography engine.
2017-08-25 10:31:11 -04:00
Peter Hamilton c5cf2c3846 Merge pull request #323 from OpenKMIP/feat/add-encrypt-decrypt-demos
Add ProxyKmipClient demos for the Encrypt / Decrypt operations
2017-08-21 16:52:44 -04:00
Peter Hamilton b0d454da9a Add ProxyKmipClient demos for the Encrypt / Decrypt operations
This change adds demos for the ProxyKmipClient, demonstrating how
to encrypt and decrypt messages. Demo utilities have been updated
to support the new demo scripts and the KMIPProxy client has been
updated to correctly return operation results.
2017-08-15 11:10:57 -04:00
Peter Hamilton 89c997c337 Add support for asymmetric encryption and decryption
This change updates the encrypt/decrypt support in the cryptography
engine to support asymmetric key algorithms, specifically RSA. Unit
tests have been added to validate the new functionality.
2017-08-14 21:10:12 -04:00
Peter Hamilton 0009bb2b5a Enforce server support for DeriveKey truncation
This change updates DeriveKey support in the software server to
enforce key truncation. If the derived key is longer than the
requested cryptographic length, the derived key is truncated to
fit the requested length. A unit test has been added to cover
this update.
2017-08-09 15:58:03 -04:00
Peter Hamilton 6071c938b6 Add DeriveKey support to the clients
This change adds DeriveKey operation support to the KMIPProxy and
ProxyKmipClient clients, including unit tests to cover the new
functionality.
2017-08-08 14:54:48 -04:00
Peter Hamilton 278a54320c Merge pull request #297 from OpenKMIP/feat/add-decrypt-to-clients
Add Decrypt support to the clients
2017-07-27 12:31:33 -04:00