tursodatabase / libsql-client-go

Go client API for libSQL
MIT License
166 stars 23 forks source link

Add support for ?tls=0 query parameter #32

Closed honzasp closed 1 year ago

honzasp commented 1 year ago

This parameter can be used to opt out of TLS when using libsql: URL. It is also possible to use it with HTTP and WebSocket URLs, but in this case we just check that it matches the existing scheme (i.e., https://localhost?tls=0 throws an error). We also require every libsql: URL with ?tls=0 to specify an explicit port, because the default port for libsql: URL is 443, which could produce unexpected results.

If the URL contains unsupported query parameters, we now return an error. This provides compatibility with other clients and makes it easier for users to debug issues.

This also makes sure that we don't send the parsed query parameters (such as the auth token) to the server. The code apparently attempted to do so by calling url.Query().Del(), but this modifies only a temporary copy of the parsed query parameters, not the original URL, so we were still sending the auth token in the query string to the server.