Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Temporal Connection Configuration with SSL Support and Flexibility #83

Open
wants to merge 10 commits into
base: 3.x
Choose a base branch
from

Conversation

butschster
Copy link
Member

This PR introduces the ability to configure multiple connections to Temporal servers, including SSL-enabled connections. It aims to provide greater flexibility and security in connection setup, improving upon the previous single-address configuration approach.

Key Changes

  • Added support for defining multiple connection options, including SSL configurations, in a structured array format.
  • Introduced SslConnection for SSL-specific settings.
  • Enabled dynamic connection selection based on environment variables.

Previous Configuration:

<?php

return [
   'address' => env('TEMPORAL_ADDRESS', '127.0.0.1:7233'),
];

**New Configuration:

<?php

use Spiral\TemporalBridge\Connection\DsnConnection;
use Spiral\TemporalBridge\Connection\SslConnection;

return [
    'connection' => env('TEMPORAL_CONNECTION', 'default'),
    'connections' => [
        'default' => new DsnConnection(
            address: env('TEMPORAL_ADDRESS', 'localhost:7233'),
        ),
        'ssl' => new SslConnection(
            address: env('TEMPORAL_ADDRESS', 'localhost:7233'),
            crt: '/path/to/crt',
            clientKey: '/path/to/clientKey',
            clientPem: '/path/to/clientPem',
            overrideServerName: 'overrideServerName',
        ),
    ],
];

Motivation

Enhancing security and deployment flexibility by supporting SSL connections and allowing configurations to adapt dynamically to different environments.

Testing & Backward Compatibility

  • Conducted tests confirm both the new SSL configurations and the default non-SSL connections work as expected.
  • The update maintains backward compatibility with the existing single-address configuration approach.

…pport

This commit significantly overhauls the Temporal connection configuration system. The previous configuration was limited to specifying a single Temporal address with no support for SSL connections. With the new setup, developers can now define multiple connection options, including SSL-enabled connections.

Changes include:
- Introduction of a 'connections' array to specify multiple connection types (e.g., `default`, `SSL`).
- Addition of the `SslConnection` class to handle SSL connection parameters such as certificates and keys.
- Preservation of backward compatibility by supporting the previous `address` configuration under the `default` connection type.
@butschster butschster added the enhancement New feature or request label Mar 22, 2024
@butschster butschster added this to the 3.x milestone Mar 22, 2024
@butschster butschster self-assigned this Mar 22, 2024
Copy link

codecov bot commented Mar 22, 2024

Codecov Report

Attention: Patch coverage is 97.22222% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 98.68%. Comparing base (38be446) to head (5b84286).
Report is 6 commits behind head on 3.x.

Current head 5b84286 differs from pull request most recent head b6f7891

Please upload reports for the commit b6f7891 to get more accurate results.

Files Patch % Lines
src/Config/TemporalConfig.php 93.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                3.x      #83      +/-   ##
============================================
- Coverage     99.14%   98.68%   -0.47%     
- Complexity      103      110       +7     
============================================
  Files            15       18       +3     
  Lines           352      380      +28     
============================================
+ Hits            349      375      +26     
- Misses            3        5       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@butschster butschster linked an issue Mar 22, 2024 that may be closed by this pull request
@butschster butschster requested a review from wolfy-j March 22, 2024 06:43
src/Connection/TemporalCloudConnection.php Outdated Show resolved Hide resolved
src/Connection/SslConnection.php Outdated Show resolved Hide resolved
src/Connection/Connection.php Outdated Show resolved Hide resolved
src/Connection/Connection.php Outdated Show resolved Hide resolved
@@ -6,6 +6,9 @@

class Connection
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class Connection
class InsecureConnection

@roxblnfk
Copy link
Member

See temporalio/sdk-php#410
Consider incorporating a new authentication method - Bearer Token

@roxblnfk
Copy link
Member

See temporalio/sdk-php#418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SSL connection support
2 participants