dongjoon-hyun opened a new pull request, #596: URL: https://github.com/apache/spark-connect-swift/pull/596
### What changes were proposed in this pull request? This PR aims to enable TLS in `SparkConnectClient` whenever an authentication token is set, even if `use_ssl=true` is not specified, like the Python client. - The token can come from the `token=` connection string parameter or the `SPARK_CONNECT_AUTHENTICATE_TOKEN` environment variable. - `localhost` is excepted and stays plaintext unless `use_ssl=true` is given, like the Python client, which uses local channel credentials in that case. - Update `SecurityGuide.md` accordingly. - Add the `tokenEnforcesTLS` test. ### Why are the changes needed? Currently, the client sends the `Authorization: Bearer` header over a plaintext connection if the connection string has a token but no `use_ssl=true`. This exposes the token to interception. The Python client treats a connection as secure when either `use_ssl=true` or a token is set (`secure = use_ssl or token is not None`), so this PR aligns the behavior. The `localhost` exception keeps the existing CI, which connects to a local server with `SPARK_CONNECT_AUTHENTICATE_TOKEN` over plaintext, working. ### Does this PR introduce _any_ user-facing change? Yes. When a token is set and the host is not `localhost`, the client now connects with TLS even without `use_ssl=true`. Previously, it connected with plaintext. If the server does not support TLS, the connection fails. ### How was this patch tested? Passed `swift build`. Added the `tokenEnforcesTLS` test, which does not require a Spark Connect server, and it verifies the following. - `sc://host1:123/;token=abc` uses TLS. - `sc://localhost:123/;token=abc` stays plaintext. - `sc://localhost:123/;token=abc;use_ssl=true` uses TLS. The new test was not run in my local environment because Xcode is not installed (`no such module 'Testing'`), so it relies on CI. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Sonnet 5.5 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
