Closed PietrH closed 1 month ago
I suppose connect_to_etn()
should remain functional as we are now going down the road of soft deprecation
Yeah, I guess:
At the moment, the SQL versions of the functions themselves use connect_to_etn()
to create database connections like so:
connection <- do.call(connect_to_etn, get_credentials())
So:
What do you prefer?
Credentials are can be leaked via RHistory or scripts because people are encouraged to enter their password directly:
connect_to_etn(username = Sys.getenv("userid"), password = Sys.getenv("pwd"))
I'm currently still storing credentials as environmental variables, just like rgbif, but i'd prefer to use something like keyring in the future. This is why the new functions prompt the user, instead of allowing them to enter directly. I'm also using a dependency (askpass) for the password, using the RStudio API so this vital secret can't end up captured somewhere where it doesn't belong.
Any root/sudo user, or any child processes of the current user can access these credentials. It's non trivial for other users to get to them, but environmental variables still aren't a good place to store passwords in my opinion.
Users that currently experience:
library(etn)
con <- connect_to_etn()
con
#> <OdbcConnection> peter.desmet@inbo.be@pgetn.vliz.be
#> Database: ETN
#> PostgreSQL Version: 14.0.13
animals <- get_animals(con, animal_id = 305)
Should get something like:
library(etn)
con <- connect_to_etn()
#> Deprecation warning:
#> connect_to_etn() has been deprecated since etn 2.3.0.
#> You will be prompted for credentials instead.
con
#> NULL
animals <- get_animals(con, animal_id = 305)
#> Deprecation warning:
#> `connection` has been deprecated since etn 2.3.0.
#> You will be prompted for credentials instead.
So I prefer:
Hard deprecate, return NULL, add new helper.
This will also make it clearer to us developers to no longer rely on connect_to_etn()
.
I agree, that seems to be the cleanest way forward!
TODO
connect_to_etn()
connect_to_etn()
to NULLconnect_to_etn()
: should provide deprecation messageconnect_to_etn()
connect_to_etn()
connect_to_etn()
only fail in test package on RStudio VLIZAll examples work again, but they still need to be updated: #308
I'm having a strange issue where the new tests for the deprecation message for
connect_to_etn()
fail on the RStudio VLIZ server, but only when I call test package ordevtools::test(filter = "connect_to_etn")
, not when running the tests directly or clicking run tests. Very strange. I also can't replicate it locally. Visually the warning message looks fine.