These functions interrogate the R process to determine what valid modes of asking for credentials might be. For example the shiny app will work with R GUI and RStudio, but is somewhat cumbersome (and maybe entirely impractical) for command line R (especially when operating over SSH).
list_credentialing_options() get_recommended_credentialer() get_first_available_credentialer(preferences) is_readline_credentialing_available() is_readline_credentialing_recommended() is_rstudioapi_credentialing_available() is_rstudioapi_credentialing_recommended() is_shiny_credentialing_available() is_shiny_credentialing_recommended() is_tcltk_credentialing_available() is_tcltk_credentialing_recommended()
preferences | Character. An ordered list of preferred credentialing options. The first
option on the list that is functional on the user's system will be used. Note that in the
event that none of the preferred options is available on a user's system, then all
available options (per |
---|
Credentialing via readline
is available when R
is
run on a terminal (i.e., command line R
). It is not recommended
when running using a GUI because it depends on system commands to
turn off echoing of typed text - which is how it prevents passwords
from showing up in the console in plain text. This is a method of
last resort and is only recommended when the GUI-based options are
not available.
In the case that a user is running R with a GUI and no other credentialing
options are available, then as a last resort the readline
approach
can be used with a plain_text
option. This at least prevents a
user's password from persisting in a command history (e.g., if the password
were entered when calling a function) but it is exposed in plain text on the
console. If this happens a warning message will be printed explaining how
a user might go about installing a package to enable veiled password entry.
Credentialing via the rstudioapi
package is available when R
is
run using the RStudio IDE and not otherwise. It is the preferred approach if
it is available and the dependencies required for shiny
credentialing
are not installed.
Shiny credentialing depends on both the shiny
and miniUI
packages being available.
It also requires that R
is being run using a GUI (e.g., not on the command line). Shiny
is designated as the recommended option when R is run via RStudio and the necessary dependencies
are available. While this may seem odd given that there is an rstudioapi
credentialing
option, the shiny
option is superior in that it is the only option to provide an optional
cache password checkbox and is also the only option where the user can modify the user name input
after the function is called.
Credentialing via tcltk
is available when R
tcltk
is available.
This means that R
was compiled with tcltk
(see ?capabilities
)
and the tcltk
package is installed. One additional special check is that R
is not running under RStudio Server. This special case is needed because RStudio Server
can pass the first checks, but tcltk
fails to pop up a window on top of the
web browser serving out RStudio in that case. Checking for a display is not sufficient
because R GUI reports no display but is in principle able to use tcltk
. This method
is recommended as an option when both shiny
and rstudioapi
approaches are
unavailable.