-
Notifications
You must be signed in to change notification settings - Fork 131
Make env config TLS disabled
field optional
#1105
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
Conversation
set_source("client_key", self.client_private_key) | ||
return d | ||
|
||
def to_connect_tls_config(self) -> Union[bool, temporalio.service.TLSConfig]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, the default of TLS (i.e. neither true nor false) was that it was implicitly enabled if there was an API key present, otherwise implicitly disabled. I think we need to respect that behavior in the SDKs (IIRC, Go does).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is the behaviour of this function, we only return False
(instead of a TLSConfig
) if disabled
is explicitly enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or are you saying that if a user supplies an api key AND sets disabled
to explicitly true
, that the api-key would take precedence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, this case:
"""
[profile.default]
address = "{target_host}"
[profile.default.tls]
disabled = false
server_name = "my-server"
"""
technically, TLS is enabled here, there's no restriction as long as don't set disabled
as true
. We'd basically pass an empty TLSConfig
to the client on the connect
call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the test in this commit lays out the various cases:
9423e82
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue actually is at to_client_connect_config
. So if ClientConfigProfile.api_key
is present CleintConfigProfile.tls
is None
, does tls
get enabled? It doesn't seem so from the code, but it should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done in core:
/// Apply automatic TLS enabling when API key is present
pub fn apply_api_key_tls_logic(&mut self) {
if self.api_key.is_some() && self.tls.is_none() {
// If API key is present but no TLS config exists, create one with TLS enabled
self.tls = Some(ClientConfigTLS::default());
}
}
though now, given that we have logic in lang to transform to/from object that should represent the TOML, this may no longer be desired/accurate.
Probably the best solution here is to change pub tls: Option<ClientConfigTLS>
in core to:
pub enum ConfigTlsEnum {
Enabled(bool), // TLS enabled, default options (i.e. api key but no tls)
Config(ClientConfigTLS), // TLS explicitly configured
}
and then:
pub tls: Option<ConfigTlsEnum> // null is no api key or TLS configuration
alternatively, we keep core as is and make the change upstream in the bridge, with the logic being something like "if received TLS object is ClientConfigTLS::default()
, then transform to true
"
or we remove apply_api_key_tls_logic
from core altogether and have lang implement this logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am leaning towards the latter, will open a PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4e328ed
to
9423e82
Compare
…SDK now sets TLS to True if api key provided with no TLS configuration (default TLS config)
What was changed
Made the TLS
disabled
field in env configOptional
, to reflect it's tri-state:true
-> explicitly enabledfalse
-> explicitly disabledNone
-> not configuredAdded a few tests for better e2e coverage
Why?
This representation mimics the TOML configuration when serialized, where as before,
disabled
would be serialized even if it wasn't set in the TOML config.