使用 RGoogleDocs 时如何防止密码泄露?如何防止、密码、RGoogleDocs

2023-09-07 09:31:49 作者:你的勇气呢

我喜欢 .在使用 RGoogleDocs 时,它没有给我足够的信息来隐藏我的密码.

解决方案

我的做法是设置登录名&R选项列表中的密码在 R 启动文件 .Rprofile 中.然后我的代码得到值使用 getOption() 然后该值永远不可见或存储在 globalenv() 的顶级变量中.(如果可以保存一个通过 dump.frames 进行事后调试).

8招教你如何防范个人信息泄露

.Rprofile 不能被您以外的任何人读取,这一点至关重要.

所以

options(GoogleDocsPassword = c(login = 'password'))

.Rprofile 然后

auth = getGoogleAuth()

第一个参数的默认值只是查找 GoogleDocsPassword 选项.

D.

I love RGoogleDocs and use it a lot. However, I don't like entering my password all the time. Obviously I could just type the password into the R script and would never have to enter it again. But thats not viable since it means that my password would be left unencrypted on my harddrive. Furthermore I share my scripts with colleagues.

To get around the problem I came up with this.

if(exists("ps")){
  print("got password, keep going")
} else {
  ps <-readline(prompt="get the password in ")
}

options(RCurlOptions = list(
  capath = system.file("CurlSSL", "cacert.pem", 
  package = "RCurl"), ssl.verifypeer = FALSE)
)

sheets.con = getGoogleDocsConnection(
  getGoogleAuth("notreal@gmail.com", ps, service ="wise")) 

#WARNING: this would prevent curl from detecting a 'man in the middle' attack
ts2=getWorksheets("hpv type",sheets.con)

I love using RStudio. I feel uncomfortable that it is displaying my password for any colleague in my office at the time to see. I used a fake password but look at the image. . Furthermore, if I saved a workspace my password would be saved with it and I am afraid that I would be giving it to someone else if, a few months later, when I had long forgotten about what was in it, I sent my .RData file to a colleague.

I read something general about passwords in R in an earlier post. It did not give me enough information to be able to conceal my password when using RGoogleDocs.

解决方案

My approach is to set the login-name & password in the R options list within the R startup file .Rprofile. Then my code gets the value with getOption() and then the value is never visible or stored in a top-level variable in globalenv(). (It could be save if one does post-mortem debugging via dump.frames).

It is vital that the .Rprofile cannot be read by anybody other than you.

So

options(GoogleDocsPassword = c(login = 'password'))

in the .Rprofile and then

auth = getGoogleAuth()

just works as the default value for the first parameter is to look for the GoogleDocsPassword option.

D.